adplus-dvertising
frame-decoration

Question

What will be the output of the following program code?
main()
{
      static int var = 5;
      printf("%d ", var--);
      if(var)
            main();
}

a.

5 5 5 5 5

b.

5 4 3 2 1

c.

Infinite Loop

d.

Compilation Error

Posted under C Programming

Answer: (b).5 4 3 2 1

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What will be the output of the following program code?

Similar Questions

Discover Related MCQs

Q. Which of the following is a complete function?

Q. The recursive functions are executed in a ...........

Q. The function scanf() returns .........

Q. Functions have ..........

Q. Which of the following function calculates the square of 'x' in C?

Q. When a function is recursively called all the automatic variables are stored in a ..........

Q. Inner Block can access variables declared ___________.

Q. Can we declare same variable inside the inner and outer block ?

Q. How would you round off a value from 1.66 to 2.0?

Q. By default a real number is treated as a

Q. The keyword used to transfer control from a function back to the calling function is

Q. What is the notation for following functions?
1. int f(int a, float b)
{
/* Some code */
}

2. int f(a, b)
int a; float b;
{
/* Some code */
}

Q. In the following 'C' code, in which order the functions would be called ?

a = ( f1(23,14 ) * f2 (12/14)) + f3 () ;

Q. The function that actually created from a call to a template function is called

Q. A function that is prototype as

int calculate(int num);

may

Q. A function that uses variable types is called

Q. A function that is prototyped as double calculate (int, num);
may

Q. The declaration

void function1(int)

indicates the function1 is a function which

Q. The function fprintf is used in a program

Q. The function is lower(char) checks whether a character is in lower case or not, therefore it should return