Welcome Guest | Sign in | Register
If statements - Discussion Page For Q.10482 | C Programming Questions and Answers | C Programming Free Online-Tests | LucentBlackBoard | LucentBlackBoard.com

Home > Java Programming > If statements > Questions and Answers

Q: What is the output of following C code?
main()
{
static int var = 5;
printf("%d ",var--);
if(var)
main();
}
A. 5 4 3 2 1 B. 4 3 2 1
C. 3 2 1 D. 5 4 3 2
E. 5 4 3 2 1 0

Answer and Explanation

Answer:5 4 3 2 1

Explanation:
When static storage class is given, it is initialized once. The change in the value of a static variable is retained even between the function calls. Main is also treated like any other ordinary function, which can be called recursively.

Comment on this Question

Name:

Loading...




Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.