Wednesday, 1 March 2017

C Programming Questions with Explanation

Q:: C programming:::
What will be the output?
void main()
{
         static int i=0;
         if(++i)
        {
                  printf("℅d",i);
                  main();
        }
}

(A) 1,1,1,1...
(B) 0,0,0,0...
(C) 1,2,3,4...
(D) None of these

Answer:: (D)

Explanation:

It will go upto range of integer here we are considering int takes 2 bytes.

1,2,3,4 ...32766,32767,-32768,-32767...-2,-1

No comments:

Post a Comment