Trắc Nghiệm Ngôn Ngữ Lập Trình C ( English ) - Bài 37
1-
For the following statements will arr[3] and ptr[3] fetch the same character?
char arr[] = "IndiaBIX";
char *ptr = "IndiaBIX";
A -
Yes
B -
No
2-
Is there any difference between the two statements?
char *ch = "IndiaBIX";
char ch[] = "IndiaBIX";
A -
Yes
B -
No
3-
How will you free the allocated memory ?
A -
remove(var-name);
B -
free(var-name);
C -
delete(var-name);
D -
dalloc(var-name);
4-
What is the similarity between a structure, union and enumeration?
A -
All of them let you define new pointers
B -
All of them let you define new values
C -
All of them let you define new data types
D -
All of them let you define new structures
5-
What will be 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 -
515, 515, 4
6-
What will be the output of the program ?
#include<stdio.h>
int main()
{
union var
{
int a, b;
};
union var v;
v.a=10;
v.b=20;
printf("%d\n", v.a);
return 0;
}
A -
10
B -
20
C -
30
D -
0
7-
What will be the output of the program ?
#include<stdio.h>
int main()
{
struct value
{
int bit1:1;
int bit3:4;
int bit4:4;
}bit={1, 2, 13};
printf("%d, %d, %d\n", bit.bit1, bit.bit3, bit.bit4);
return 0;
}
A -
1, 2, 13
B -
1, 4, 4
C -
-1, 2, -3
D -
-1, -2, -13
8-
What will be the output of the program in 16 bit platform (Turbo C under DOS) ?
#include<stdio.h>
int main()
{
struct value
{
int bit1:1;
int bit3:4;
int bit4:4;
}bit;
printf("%d\n", sizeof(bit));
return 0;
}