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; }; struct student fun(void) { struct student s; s.name = "alan"; return s; } void main() { struct student m = fun(); s.name = "turing"; printf("%s", m.name); }
Q2
What will be the output of the following C code? #include <stdio.h> struct student { char *c; struct student *point; }; void main() { struct student s; struct student m; m.point = s; (m.point)->c = "hey"; printf("%s", s.c); }
Q3
What will be the output of the following C code? #include <stdio.h> int (*(x()))[2]; typedef int (*(*ptr)())[2] ptrfoo; int main() { ptrfoo ptr1; ptr1 = x; ptr1(); return 0; } int (*(x()))[2] { int (*ary)[2] = malloc(sizeof*ary); return &ary; }
Q4
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(ptr1)); if (x == 1) printf("%d\n", ptr1->x); else printf("false\n"); }
Q5
What will be the output of the following C code? #include <stdio.h> union stu { int ival; float fval; }; void main() { union stu r; r.ival = 5; printf("%d", r.ival); }
Q6
What will be the output of the following C code? #include <stdio.h> struct p { int x; int y; }; int main() { struct p p1[] = {1, 92, 3, 94, 5, 96}; struct p *ptr1 = p1; int x = (sizeof(p1) / 5); if (x == 3) printf("%d %d\n", ptr1->x, (ptr1 + x - 1)->x); else printf("false\n"); }
Q7
What will be the output of the following C code? #include <stdio.h> struct student { char *c; struct student *point; }; void main() { struct student s; struct student *m = &s; printf("%d", sizeof(student)); }
Q8
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.p = {2}; printf("%d\n", u.p.x); }
Q9
What will be the output of the following C code? #include <stdio.h> union { int x; char y; }p; int main() { p.y = 60; printf("%d\n", sizeof(p)); }
Q10
Bit fields can only be declared as part of a structure.
Q11
Members of a union are accessed as . . . . . . . .
Q12
For what minimum value of x in a 32-bit Linux OS would make the size of s equal to 8 bytes? struct temp { int a : 13; int b : 8; int c : x; }s;
Q13
Which of the following uses structure?
Q14
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, q; p.name = "xyz"; p.next = NULL; ptrary[0] = &p; strcpy(q.name, p.name); ptrary[1] = &q; printf("%s\n", ptrary[1]->name); return 0; }
Q15
Which of the following cannot be a structure member?
Q16
Which of the following reduces the size of a structure?
Q17
The correct syntax to access the member of the ith structure in the array of structures is? Assuming: struct temp { int b; }s[50];
Q18
What will be the output of the following C code? #include <stdio.h> struct student { char *c; }; void main() { struct student n; struct student *s = &n; (*s).c = "hello"; printf("%p\n%p\n", s, &n); }
Q19
What will be the output of the following C code? #include <stdio.h> struct p { unsigned int x : 1; unsigned int y : 1; }; int main() { struct p p; p.x = 1; p.y = 2; printf("%d\n", p.y); }
Q20
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}; foo(&p1); } void foo(struct point *p) { printf("%d\n", *p->x++); }
Q21
What is the order for the following C declarations? short a : 17; int long y : 33;
Q22
What will be the output of the following C code? #include <stdio.h> struct student { char *c; struct student point; }; void main() { struct student s; s.c = "hello"; printf("%s", s.c); }
Q23
Which of the following data types are accepted while declaring bit-fields?
Q24
Presence of loop in a linked list can be tested by . . . . . . . .
Q25
Which option should be selected to work the following C expression? string p = "HELLO";