Question 1 of 25
Hints left: 3
Q1
What will be the output of the following C code? #include <stdio.h> union u { struct { unsigned char x : 2; unsigned int y : 2; }p; int x; }; int main() { union u u; u.p.x = 2; printf("%d\n", u.p.x); }
Q2
What will be the output of the following C code? #include <stdio.h> struct student { int no; char name[20]; } void main() { struct student s; s.no = 8; printf("hello"); }
Q3
What will be the output of the following C code? #include <stdio.h> struct student { char *name; }; struct student s; struct student fun(void) { s.name = "newton"; printf("%s\n", s.name); s.name = "alan"; return s; } void main() { struct student m = fun(); printf("%s\n", m.name); m.name = "turing"; printf("%s\n", s.name); }
Q4
Which of the following is false about typedef?
Q5
What will be the output of the following C code? #include <stdio.h> struct student { char *c; }; void main() { struct student s[2]; printf("%d", sizeof(s)); }
Q6
What will be the output of the following C code? #include <stdio.h> union p { int x; char y; }; int main() { union p p, b; p.y = 60; b.x = 12; printf("%d\n", p.y); }
Q7
What will be the output of the following C code? #include <stdio.h> struct { int k; char c; } p; int p = 10; int main() { p.k = 10; printf("%d %d\n", p.k, p); }
Q8
What will be the output of the following C code? #include <stdio.h> typedef struct p { int x, y; }; int main() { p k1 = {1, 2}; printf("%d\n", k1.x); }
Q9
Which of the following return-type cannot be used for a function in C?
Q10
What will be the output of the following C code? #include <stdio.h> struct point { int x; int y; }; void foo(struct point*); int main() { struct point p1[] = {1, 2, 3, 4}; foo(p1); } void foo(struct point p[]) { printf("%d %d\n", p->x, ++p->x); }
Q11
Which member of the union will be active after REF LINE in the following C code? #include <stdio.h> union temp { int a; float b; char c; }; union temp s = {1,2.5,’A’}; //REF LINE
Q12
Which of the following structure declaration will throw an error?
Q13
What will be the output of the following C code? #include <stdio.h> struct student { int no = 5; char name[20]; }; void main() { struct student s; s.no = 8; printf("hello"); }
Q14
What type of data is holded by variable u int in the following C code? #include <stdio.h> union u_tag { int ival; float fval; char *sval; } u;
Q15
What will be the output of the following C code? #include <stdio.h> typedef int integer; int main() { int i = 10, *ptr; float f = 20; integer j = i; ptr = &j; printf("%d\n", *ptr); return 0; }
Q16
The number of distinct nodes the following struct declaration can point to is . . . . . . . . struct node { struct node *left; struct node *centre; struct node *right; };
Q17
What will be the output of the following C code according to C99 standard? #include <stdio.h> struct p { int k; char c; float f; }; int main() { struct p x = {.c = 97, .k = 1, 3}; printf("%f \n", x.f); }
Q18
What will be the output of the following C code? #include <stdio.h> struct p { int k; char c; float f; }; int p = 10; int main() { struct p x = {1, 97}; printf("%f %d\n", x.f, p); }
Q19
Which function is responsible for recording the name "s" and the replacement text "t" in a table?
Q20
What will be the output of the following C code? #include <stdio.h> struct p { unsigned int x : 2; unsigned int y : 2; }; int main() { struct p p; p.x = 3; p.y = 1; printf("%d\n", sizeof(p)); }
Q21
What will be the output of the following C code according to C99 standard? #include <stdio.h> struct p { int k; char c; float f; }; int main() { struct p x = {.c = 97, .f = 3, .k = 1}; printf("%f\n", x.f); }
Q22
In the following declaration of bit-fields, the constant-expression specifies . . . . . . . . struct-declarator: declarator type-specifier declarator opt : constant-expression
Q23
What will be the output of the following C code? #include <stdio.h> struct student { char *c; }; void main() { struct student m; struct student *s = &m; (*s).c = "hello"; printf("%s", m.c); }
Q24
What happens when install(s, t) finds that the name being installed is already present in the table?
Q25
What will be the output of the following C code? #include <stdio.h> struct point { int x; int y; }; void foo(struct point*); int main() { struct point p1[] = {1, 2, 3, 4}; foo(p1); } void foo(struct point p[]) { printf("%d\n", p[1].x); }