C Programming - Declarations and Initializations
Exercise : Declarations and Initializations - Find Output of Program
- Declarations and Initializations - General Questions
- Declarations and Initializations - Find Output of Program
- Declarations and Initializations - Point Out Errors
- Declarations and Initializations - Point Out Correct Statements
- Declarations and Initializations - True / False Questions
- Declarations and Initializations - Yes / No Questions
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;
}
Answer: Option
Explanation:
During the for loop execution scanf() ask input and then printf() prints that given input. This process will be continued repeatedly because, scanf() returns the number of input given, the condition is always true(user gives a input means it reurns '1').
Hence this for loop would get executed infinite times.
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;
}
Answer: Option
Explanation:
In case of a conflict between a local variable and global variable, the local variable gets priority.
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers