Variables are used for storing data in a program. Based on the data type of a variable, the compiler allocates memory and decides what can be stored in the allocated memory. The value of variable may vary during the program execution.
Declaring of a Variable:
datatype identifier;
(or)
datatype identifier-1, identifier-2, .................., identifier-n;
Eg:
int n;
char ch;
float ft;
double db;
int a, b, c, d;
char x, y, z;
Initialization of Variable:
At the time of declaring a variable, we can store some value into that variable is known as initialization.
Syntax:
datatype identifier=value;
Eg:
int n=100;
char ch='H';
float ft=10.569;
double db=123.618;
int a=10, b=20, c=30;
int x=100, y, z=200;
Next Topic : Initialization of variable with Data Types
Previous Topic : Type Modifiers: (signed, unsigned, short, long)
No comments:
Post a Comment