Use a single variable x
#include <stdio.h> int main() // w ww.j a v a 2s .c om { int x; x = 5; printf("The value of variable x is %d.\n",x); return(0); }
Every variable used in C must be declared as a specific variable type and assigned a name.
The variable in the code above is declared as an integer (int) and given the name x.
Then the code assigns the value 5 to variable x.
The value goes on the right side of the equal sign. The variable goes on the left.
After that the code uses the variable's value in the printf() statement.
The %d conversion character is used because the variable contains an integer value.
The conversion character must match the variable.