by Dinesh Thakur Category: Type And 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. In order to see how this can be done let us see an 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.

 



About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.