icp/oer/courses/c-basics/sections/02-basic-language-features/01-variables/program.c

34 lines
945 B
C
Raw Normal View History

2018-05-05 22:18:02 +00:00
#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;
}