Exercise :: Declarations and Initializations – General Questions
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
6.
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
7.
Point out the error in the following program.
#include<stdio.h>
int main()
{
void v = 0;
printf(“%d”, v);
return 0;
}
A. Error: Declaration syntax error ‘v’ (or) Size of v is unknown or zero.
B. Program terminates abnormally.
C. No error.
D. None of these.
8.
Is it true that a function may have several declarations, but only one definition?
A. Yes
B. No
9.
Which of the declaration is correct?
A. int length;
B. char int;
C. int long;
D. float double;
10.
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