Computer-Networks
December 1, 2023
Question 8878 – ISRO CS 2020
December 1, 2023
Computer-Networks
December 1, 2023
Question 8878 – ISRO CS 2020
December 1, 2023

Programming-for-Output-Problems

Question 19
What will be the output of following?
main()
{
static int a=3;
printf(“%d”,a–);
if(a)
main();
}
A
3
B
3 2 1
C
3 3 3
D
Program will fall in continuous loop and print 3
Question 19 Explanation: 
Step-1: initial a=3 but we are given storage class is static.
Step-2: In printf( ) we are given post decrement. So, it will print 3 then decrements.
Step-3: if(2) then we are calling main() function, a=2 because of static otherwise it will be 3 only.
Step-4: It will print 2 and next iteration will print 1.
Correct Answer: B
Question 19 Explanation: 
Step-1: initial a=3 but we are given storage class is static.
Step-2: In printf( ) we are given post decrement. So, it will print 3 then decrements.
Step-3: if(2) then we are calling main() function, a=2 because of static otherwise it will be 3 only.
Step-4: It will print 2 and next iteration will print 1.
0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
error: Alert: Content selection is disabled!!