C Programming : Declarations and Initializations

0
661
11. In the following program how long will the for loop get executed?
#include<stdio.h>
int main()
{
int i=5;
for(;scanf("%s", &i); printf("%d\n", i));
return 0;
}
A. The for loop would not get executed at all
B. The for loop would get executed only once
C. The for loop would get executed 5 times
D. The for loop would get executed infinite times
Answer: Option D 
12. What will be the output of the program? 
#include<stdio.h>
int main()
{
int X=40;
{
int X=20;
printf("%d ", X);
}
printf("%d\n", X);
return 0;
}
A. 40 40
B. 20 40
C. 20
D. Error
Answer: Option B Explanation: In case of a conflict between a local variable and global variable, the local variable gets priority. 

 

TAGS: C Programming: Declarations and Initializations » Find Output of Program, C Programming, Declarations, and Initializations, Find Output of Program, c programming basics, c programming language, c programming patterns, c programming tutorial, c programming example, c programming pdf, for c programming example, c programming questions, c programming questions, and answer

 

www.GKDuniya.in will update many more new jobs and study materials and exam updates, keep Visiting and share our post of Gkduniya.in, So more people will get this. This content and notes are not related to www.GKDuniya.in and if you have any objection over this post, content, links, and notes, you can mail us at gkduniyacomplaintbox@gmail.com

And you can follow and subscribe to other social platforms. All social site links in the subscribe tab and bottom of the page.

Important Links

Youtube:- GKDuniya9
Instagram:- GKDuniya.in
Facebook:– GKDuniya.in