Question 11
#include \"stdio.h\"
int main()
{
struct {int a[2];} arr[] = {{1},{2}};
printf(\"%d %d %d %d\",arr[0].a[0],arr[0].a[1],arr[1].a[0],arr[1].a[1]);
return 0;
}
Question 12
#include \"stdio.h\"
int main()
{
struct {int a[2], b;} arr[] = {[0].a = {1}, [1].a = {2}, [0].b = 1, [1].b = 2};
printf(\"%d %d %d and\",arr[0].a[0],arr[0].a[1],arr[0].b);
printf(\"%d %d %d\\n\",arr[1].a[0],arr[1].a[1],arr[1].b);
return 0;
}
Question 13
Pick the best statement for the below program:
#include <stdio.h>
int main()
{
struct {
int i;
char c;
} myVar = {.i = 100, .c = 'A'};
printf("%d %c", myVar.i, myVar.c);
return 0;
}
Question 14
Pick the best statement for the below program:
#include <stdio.h>
int main()
{
union {
int i1;
int i2;
} myVar = {.i2 = 100};
printf("%d %d", myVar.i1, myVar.i2);
return 0;
}
Question 15
Consider the following declaration :
struct addr { char city[10]; char street[30]; int pin ; }; struct { char name[30]; int gender; struct addr locate; } person , *kd = &person ;
Then *(kd -> name +2) can be used instead of
Question 16
Consider the following ANSI C program:
int main () { Integer x; return 0; }
Which one of the following phases in a seven-phase C compiler will throw an error?
Question 17
Consider the following C declaration
struct ( short s[5]; union { float y; long z; }u; }t;
Assume that the objects of the type short, float and long occupy 2 bytes, 4 bytes and 8 bytes, respectively. The memory requirement for variable t, ignoring alignment consideration, is
Question 18
Consider the following C declaration
struct {
short s[5];
union {
float y;
long z;
}u;
} t;
Assume that objects of the type short, float and long occupy 2 bytes, 4 bytes and 8 bytes, respectively. The memory requirement for variable t, ignoring alignment considerations, is (GATE CS 2000)
Question 20
Pick the best statement for the below program snippet:
struct {int a[2];} arr[] = {1,2};
There are 22 questions to complete.