#include <stdio.h>
int main()
{
int age;
age = 23;
printf("Hello world!\n");
printf("My age is %d.\n", age);
return 0;
}
|
- Here's how to declare a variable. In this example, we declare a variable
called age with a type of int.
- A variable of type int can only store integer values.
- Other types available in C/C++ are:
- float -- To store fractional numbers.
- char -- To store letters (or, to be exact, characters).
- long -- To store integer values, but it has bigger capacity
than int.
|