Question 1 of 25
Hints left: 3
Q1
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) / 3); if (x == sizeof(int) + sizeof(char)) printf("%d\n", ptr1->x); else printf("falsen"); }
Q2
In the following declaration of bit-fields, the constant-expression must be . . . . . . . . struct-declarator: declarator type-specifier declarator opt : constant-expression
Q3
In what situation, install function returns NULL?
Q4
What will be the output of the following C code? #include <stdio.h> union p { int x; float y; }; int main() { union p p, b; p.x = 10; printf("%f\n", p.y); }
Q5
Which of the given option is the correct method for initialization? typedef char *string;
Q6
Calculate the % of memory saved when bit-fields are used for the following C structure as compared to with-out use of bit-fields for the same structure? (Assuming size of int = 4) struct temp { int a : 1; int b : 2; int c : 4; int d : 4; }s;
Q7
What would be the size of the following union declaration? (Assuming size of double = 8, size of int = 4, size of char = 1) #include <stdio.h> union uTemp { double a; int b[10]; char c; }u;
Q8
What will be the output of the following C code? #include <stdio.h> typedef struct student { char *a; }stu; void main() { struct stu s; s.a = "hi"; printf("%s", s.a); }
Q9
What will be the output of the following C code? #include <stdio.h> typedef struct p *q; struct p { int x; char y; q ptr; }; int main() { struct p p = {1, 2, &p}; printf("%d\n", p.ptr->ptr->x); return 0; }
Q10
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.c = m.c = "hi"; m.point = &s; (m.point)->c = "hey"; printf("%s\t%s\t", s.c, m.c); }
Q11
Which of the following statement is true?
Q12
Which of the following is not possible under any scenario?
Q13
Presence of code like "s.t.b = 10" indicates . . . . . . . .
Q14
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; s.no = 8; printf("%d", s.no); }
Q15
What will be the output of the following C code? #include <stdio.h> struct student fun(void) { struct student { char *name; }; struct student s; s.name = "alan"; return s; } void main() { struct student m = fun(); printf("%s", m.name); }
Q16
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, 2, 3, 4, 5, 6}; struct p *ptr1 = p1; printf("%d %d\n", ptr1->x, (ptr1 + 2)->x); }
Q17
Which option is not possible for the following function call? func(&s.a); //where s is a variable of type struct and a is the member of the struct.
Q18
Which of the following is an incorrect syntax to pass by reference a member of a structure in a function? (Assume: struct temp{int a;}s;)
Q19
What will be the output of the following C code? #include <stdio.h> struct point { int x; int y; } p[] = {1, 2, 3, 4, 5}; void foo(struct point*); int main() { foo(p); } void foo(struct point p[]) { printf("%d %d\n", p->x, p[2].y); }
Q20
What will be the output of the following C code? #include <stdio.h> union u { struct p { unsigned char x : 2; unsigned int y : 2; }; int x; }; int main() { union u u; u.p.x = 2; printf("%d\n", u.p.x); }
Q21
Which of the following will stop the loop at the last node of a linked list in the following C code snippet? struct node { struct node *next; };
Q22
What will be the output of the following C code? #include <stdio.h> struct student { }; void main() { struct student s[2]; printf("%d", sizeof(s)); }
Q23
What will be the output of the following C code (Assuming size of int and float is 4)? #include <stdio.h> union { int ival; float fval; } u; void main() { printf("%d", sizeof(u)); }
Q24
What will be the output of the following C code? #include <stdio.h> struct temp { int a; } s; void func(struct temp s) { s.a = 10; printf("%d\t", s.a); } main() { func(s); printf("%d\t", s.a); }
Q25
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}; printf("%f\n", x.f); }