Question 1 of 25
Hints left: 3
Q1
What will be the output of the following C code? #include <stdio.h> struct student { char *name; }; void main() { struct student s, m; s.name = "st"; m = s; printf("%s%s", s.name, m.name); }
Q2
What will be the output of the following C code? #include <stdio.h> struct p { int x[2]; }; struct q { int *x; }; int main() { struct p p1 = {1, 2}; struct q *ptr1; ptr1->x = (struct q*)&p1.x; printf("%d\n", ptr1->x[1]); }
Q3
What will be the output of the following C code? #include <stdio.h> struct p { char *name; struct p *next; }; struct p *ptrary[10]; int main() { struct p p; p->name = "xyz"; p->next = NULL; ptrary[0] = &p; printf("%s\n", p->name); return 0; }
Q4
What will be the output of the following C code? #include <stdio.h> struct student { char *c; }; void main() { struct student *s; s->c = "hello"; printf("%s", s->c); }
Q5
How many bytes in memory taken by the following C structure? #include <stdio.h> struct test { int k; char c; };
Q6
What will be the output of the following C code? #include <stdio.h> typedef struct p { int x, y; }k; int main() { struct p p = {1, 2}; k k1 = p; printf("%d\n", k1.x); }
Q7
What will be the output of the following C code? #include <stdio.h> void main() { struct student { int no; char name[20]; }; struct student s; no = 8; printf("%d", no); }
Q8
What will be the output of the following C code? #include <stdio.h> struct p { int k; char c; }; int p = 10; int main() { struct p x; x.k = 10; printf("%d %d\n", x.k, p); }
Q9
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, 5}; foo(p1); } void foo(struct point p[]) { printf("%d %d\n", p->x, p[3].y); }
Q10
What will be the output of the following C code? #include <stdio.h> void main() { char *a[3][3] = {{"hey", "hi", "hello"}, {"his", "her", "hell"} , {"hellos", "hi's", "hmm"}}; printf("%s", a[1][1]); }
Q11
What will be the output of the following C code? #include <stdio.h> void main() { char *a[3] = {"hello", "this"}; printf("%s", a[1]); }
Q12
What will be the output of the following C code? #include <stdio.h> struct student { char *name; }; struct student fun(void) { struct student s; s.name = "alan"; return s; } void main() { struct student m = fun(); printf("%s", m.name); }
Q13
How many union members can be initialized?
Q14
Can the following C code be compiled successfully? #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); }
Q15
What will be the output of the following C code? #include <stdio.h> int main() { typedef struct p *q; struct p { int x; char y; q ptr; }; struct p p = {1, 2, &p}; printf("%d\n", p.ptr->x); return 0; }
Q16
What will be the output of the following C code? #include <stdio.h> int *(*(x()))[2]; typedef int **(*ptrfoo)())[2]; int main() { ptrfoo ptr1; ptr1 = x; ptr1(); return 0; } int *(*(x()))[2] { int (*ary)[2] = malloc(sizeof * ary); return &ary; }
Q17
What will be the output of the following C code? #include <stdio.h> struct student { char *name; }; struct student s[2], r[2]; void main() { s[0].name = "alan"; s[1] = s[0]; r = s; printf("%s%s", r[0].name, r[1].name); }
Q18
What will be the output of the following C code? #include <stdio.h> struct p { int x; char y; }; int main() { struct p p1[] = {1, 92, 3, 94, 5, 96}; struct p *ptr1 = p1; int x = (sizeof(p1) / sizeof(struct p)); printf("%d %d\n", ptr1->x, (ptr1 + x - 1)->x); }
Q19
What will be the output of the following C code? #include <stdio.h> struct p { char *name; struct p *next; }; struct p *ptrary[10]; int main() { struct p p; p.name = "xyz"; p.next = NULL; ptrary[0] = &p; printf("%s\n", ptrary[0]->name); return 0; }
Q20
What will be the output of the following C code? #include <stdio.h> struct point { int x; int y; }; int main() { struct point p = {1}; struct point p1 = {1}; if(p == p1) printf("equal\n"); else printf("not equal\n"); }
Q21
What will be the output of the following C code? #include <stdio.h> union p { int x; char y; }k = {.y = 97}; int main() { printf("%d\n", k.y); }
Q22
Which of the following share a similarity in syntax? 1. Union, 2. Structure, 3. Arrays and 4. Pointers
Q23
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 = {2}; printf("%d\n", u.p.x); }
Q24
What is the correct syntax to declare a function foo() which receives an array of structure in function?
Q25
Which of the following structure declaration doesn't require pass-by-reference?