#include <stdio.h>
int main()
{
int age;
age = 23;
printf("Hello world!\n");
printf("My age is %d.\n", age);
return 0;
}
|
- Here we assign 23 into the variable age.
- Since age is of type int,
you cannot assign a fraction, say 24.5, to it.
- Remember that in C, the declaration of variables must be before
any commands. So, you cannot say:
printf("Hi!\n"); int age;
- In C++, this limitation has been lifted off.
|