Trắc Nghiệm Ngôn Ngữ Lập Trình C ( English ) - Bài 03
1-
What is the output of the program?
#include<stdio.h>
int main()
{
union a
{
int i;
char ch[2];
};
union a u;
u.ch[0] = 3;
u.ch[1] = 2;
printf("%d, %d, %d\n", u.ch[0], u.ch[1], u.i);
return 0;
}
A -
3, 2, 515
B -
515, 2, 3
C -
3, 2, 5
D -
None of these
2-
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
3-
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;
}