ISRO | ISRO CS 2017 – May | Question 62
What is the output of the following program?
#include
int tmp=20;
main( )
{
printf(\"%d \",tmp);
func( );
printf(\"%d \",tmp);
}
func( )
{
static int tmp=10;
printf(\"%d \",tmp);
}
(A)
20 10 10
(B)
20 10 20
(C)
20 20 20
(D)
10 10 10
Answer: (B)
Explanation:
Main() is the entry section of the program. First print statement will print the value of tmp = 20. Then after the function is called the 10 will be printed. After that control returns to the main function and again 20 will be printed.
So, option (B) is correct.
Quiz of this Question
Please comment below if you find anything wrong in the above post
Last Updated :
21 Mar, 2018
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...