Introduction To Programming

Why programs ? Programming is nothing but making the computers think the same way a human thinks. Programs are made for obtaining a specific solution which can even be solved by humans which when solved by us may consume time..

Saturday, January 2, 2010


#include< stdio.h >
void main()
static int a=4;
what'll be the answer?

  1. run continuously

  2. compile time error

  3. print 3 2 1 0

  4. print 4 3 2 1

For Static variable, memory is statically allocated .
At first a is declared and initialize to 4 .
a=4 is printed and then a is decreament to 3.
Then if(a) will work main will called itself . But note that now a is 3. Then it'll print 3 and a is decreament to 2. Like that it 'll print 4 3 2 1. When a=0 then if(a) is false . So it won't call main function.