How to assign values during declaration of variables
Declaring variables tells the compiler the data type the variable is assigned and no storage area is allocated during this stage. It is possible to assign values during declaration itself.
For example, consider the following program:
main()
{
int a= 50 , b= 18 % 5 ;
printf( “a=%d b=%d”,a,b);
}
The above program runs perfectly good and will not give error. In this a is assigned the value of 50 during the declaration as integer itself and similarly b is assigned the result of operation 18 % 5 which gives 3 and this assigned to b during the declaration statement itself which is perfectly correct syntax.
So the output of the above program is
a=50 b=3