Question 1 of 25
Hints left: 3
Q1
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 + 2).y); }
Q2
What will be the output of the following C code? #include <stdio.h> int main() { struct p { char *name; struct p *next; }; 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; }
Q3
What will be the output of the following C code? #include <stdio.h> struct p { char x : 2; int y : 2; }; int main() { struct p p; p.x = 2; p.y = 1; p.x = p.x & p.y; printf("%d\n", p.x); }
Q4
What will be the output of the following C code? #include <stdio.h> struct student { char a[5]; }; void main() { struct student s[] = {"hi", "hey"}; printf("%c", s[0].a[1]); }
Q5
What will be the output of the following C code? #include <stdio.h> void main() { int lookup[100] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; printf("%d", lookup[3]); }
Q6
Which of the following is not allowed?
Q7
What will be the output of the following C code? #include <stdio.h> typedef struct p *q; int main() { struct p { int x; char y; q ptr; }; struct p p = {1, 2, &p}; printf("%d\n", p.ptr->x); return 0; }
Q8
Which of the following technique is faster for travelling in binary trees?
Q9
User-defined data type can be derived by . . . . . . . .
Q10
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 = 4; printf("%d\n", p.y); }
Q11
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.x = 2; printf("%d\n", u.p.x); }
Q12
What will be the output of the following C code? #include <stdio.h> union { int x; char y; }p; int main() { p.x = 10; printf("%d\n", sizeof(p)); }
Q13
Which function is responsible for searching in the table? (For #define IN 1, the name IN and replacement text 1 are stored in a "table")
Q14
What will be the output of the following C code? #include <stdio.h> struct student { char *name; }; void main() { struct student s[2], r[2]; s[1] = s[0] = "alan"; printf("%s%s", s[0].name, s[1].name); }
Q15
What will be the output of the following C code? #include <stdio.h> int main() { struct p { char *name; struct p *next; }; struct p *ptrary[10]; struct p p, q; p.name = "xyz"; p.next = NULL; ptrary[0] = &p; q.name = (char*)malloc(sizeof(char)*3); strcpy(q.name, p.name); q.next = &q; ptrary[1] = &q; printf("%s\n", ptrary[1]->next->next->name); }
Q16
What will be the output of the following C code? #include <stdio.h> typedef struct p { int x, y; }k = {1, 2}; int main() { p k1 = k; printf("%d\n", k1.x); }
Q17
Which of the following are themselves a collection of different data types?
Q18
Which is the correct syntax to use typedef for struct?
Q19
What will be the output of the following C code? #include <stdio.h> struct point { int x; int y; }; struct notpoint { int x; int y; }; struct point foo(); int main() { struct point p = {1}; struct notpoint p1 = {2, 3}; p1 = foo(); printf("%d\n", p1.x); } struct point foo() { struct point temp = {1, 2}; return temp; }
Q20
What will be the output of the following C code? #include <stdio.h> typedef struct student { char *a; }stu; void main() { struct student s; s.a = "hey"; printf("%s", s.a); }
Q21
What will be the output of the following C code? (Assuming size of char = 1, int = 4, double = 8) #include <stdio.h> union utemp { int a; double b; char c; }u; int main() { u.c = 'A'; u.a = 1; printf("%d", sizeof(u)); }
Q22
What will be the output of the following C code? #include <stdio.h> struct student { char a[]; }; void main() { struct student s; printf("%d", sizeof(struct student)); }
Q23
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 + 2)->y); }
Q24
What will be the output of the following C code? #include <stdio.h> struct p { unsigned int x : 7; unsigned int y : 2; }; int main() { struct p p; p.x = 110; p.y = 2; printf("%d\n", p.x); }
Q25
What will be the output of the following C code? #include <stdio.h> struct student { int no; char name[20]; }; void main() { student s; s.no = 8; printf("hello"); }