...
UGC NET CS 2017 Nov- paper-3
October 5, 2023
NTA-UGC-NET 2021 Dec & 2022 June Paper-2
October 5, 2023
UGC NET CS 2017 Nov- paper-3
October 5, 2023
NTA-UGC-NET 2021 Dec & 2022 June Paper-2
October 5, 2023

Nielit Scientific Assistance IT 15-10-2017

Question 1
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 1 Explanation: 
The variable is static variable, the value is retained during multiple function calls. Initial value is 3
“A–” is post decrement so it will print “3”
if(2) condition is true and main() function will call again , Here the “a” value is 2.
“A–” is post decrement so it will print “2”
if(1) condition is true and main() function will call again Here the “a” value is 1.
“A–” is post decrement so it will print “1”
if(0) condition is false it won’t call main() function
Correct Answer: B
Question 1 Explanation: 
The variable is static variable, the value is retained during multiple function calls. Initial value is 3
“A–” is post decrement so it will print “3”
if(2) condition is true and main() function will call again , Here the “a” value is 2.
“A–” is post decrement so it will print “2”
if(1) condition is true and main() function will call again Here the “a” value is 1.
“A–” is post decrement so it will print “1”
if(0) condition is false it won’t call main() function
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!!