Explanations




1.

The variable x is extern type (extern int x) and It is declared before main(). After get the extern keyword, c compiler will search the definition of variable “x”. The variable “x” is available at the end of the code. So the value of variable “x” is 8 immediately.

Now program will work inside the main() block. There are two do-while loops.  AS we know do-while executes at least one time even that condition is false.  So program control will reach at printf statement and it will print octal number 10 which is equal to the decimal number 8.

Here “%o” is used to print the number in octal format. Inside the inner do-while loop, the while condition is “While(! -2)”. In C if we do not use any comparison operator then the default value is “=0” that means “While(!-2 =0)”. It means, while not -2 equal to 0. The zero (0) means false.  Hence program control will come out of the inner do-while loop because .   In outer do-while loop while condition is 0. That is again false. So program control will also come out of the outer do-while loop.

No comments:

Post a Comment