34 lines
945 B
C
34 lines
945 B
C
#include <stdio.h>
|
|
|
|
int main(int argc, const char *argv[])
|
|
{
|
|
// To declare a variable you first specify the type and then the identifier.
|
|
int value; // int stands for integer
|
|
|
|
// you can the use the assignement operator to assign a value to the variable.
|
|
value = 42;
|
|
|
|
// some times you want to assign a value right when you declare the variable.
|
|
int value2 = 3+5;
|
|
|
|
printf("Value: %d \n", value); // you can use a variable instead of a value
|
|
|
|
const int constant = 10;
|
|
// TODO: uncommend the next line and see what happends
|
|
// constant = 22;
|
|
|
|
|
|
// if you want to assign a new value, you can just use the assignement operator again
|
|
value = value2;
|
|
|
|
printf("Value: %d \n", value);
|
|
|
|
// you can also assign more complex expressions
|
|
value = ((3+5)*4+5+6)%3;
|
|
|
|
// TODO: declare your own variable and asign the variable constant to it
|
|
printf("Task %d", 0/*TODO: repace the o with your variable*/);
|
|
|
|
return 0;
|
|
}
|