A variable is a named memory location that can hold various values. Only the most trivial C programs do not include variables. In C, unlike some computer languages, all variables must be declared before they can be used. A variables's declaration serves one important purpose.
What type of variable is being used ?
C support five (5) types of different data types.
Type Keyword
character data char
signed whole numbers int
floating-point numbers float
double-precision floating-point number double
valueless void
Example:
#include <stdio.h>
int main(void)
{
int number;
number = 120;
printf("\n Your value is: %d \n", number);
return 0;
}
[N.T = Declares number to be an integer variable. ]
To display the value of number, the program uses this statement:
printf("\n Your value is: %d \n", number);
Output of the code |
No comments:
Post a Comment