October 5, 2023
October 5, 2023
October 5, 2023
###### NTA-UGC-NET 2021 Dec & 2022 June Paper-2
October 5, 2023
 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
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