

MCQOPTIONS
Saved Bookmarks
This section includes 91 Mcqs, each offering curated multiple-choice questions to sharpen your C Programming knowledge and support exam preparation. Choose a topic below to get started.
51. |
What will be the output of the following C code?#include <stdio.h> typedef struct N *ptr2; struct N { int n1; char n2; ptr2 ptr1; }; int main() { struct N n = {111, 222, &n}; printf("%d n", n.ptr1->ptr1->n1); return 0; } |
A. | 111 |
B. | 222 |
C. | Compilation Error |
D. | Garbage value |
E. | None of these |
Answer» B. 222 | |
52. |
What will be the output of the following C code? #include <stdio.h> int main() { typedef struct B *ptr; struct B { int num1; char num2; ptr ptr1; }; struct B b = {15, 25, &b}; printf("%d n", b.ptr1->num1); return 0; } |
A. | 25 |
B. | Compilation Error |
C. | Garbage value |
D. | 15 |
E. | None of these |
Answer» E. None of these | |
53. |
Can the following C code be compiled successfully?#include <stdio.h> struct A { int p; char q; float r; }; int main() { struct A t = {.q = 15, .r = 13, .p = 23}; printf("%f n", t.r); } |
A. | Depends on the standard |
B. | No |
C. | Depends on the platform |
D. | Yes |
E. | None of these |
Answer» E. None of these | |
54. |
What will be the output of the following C code?#include <stdio.h> void main() { struct Employee { int id; char Name[26]; }; struct Employee emp; id = 1001; printf("%d", id); } |
A. | Garbage value |
B. | Nothing |
C. | Compilation Error |
D. | 1001 |
E. | None of these |
Answer» D. 1001 | |
55. |
What will be the output of the following C code?#include <stdio.h> void main() { struct Clothes { int size; char Brand_name[50]; }; struct Clothes c; c.size = 40; printf("%d", c.size); } |
A. | Compilation Error |
B. | Garbage value |
C. | 40 |
D. | Undefined behaviour |
E. | None of these |
Answer» D. Undefined behaviour | |
56. |
What will be the output of the following C code?#include <stdio.h> struct Clothes { int size; char Brand_name[50]; }; void main() { Clothes c; c.size = 39; printf("Jockey"); } |
A. | Jockey |
B. | 39 |
C. | Compilation Error |
D. | Garbage value |
E. | None of these |
Answer» D. Garbage value | |
57. |
What will be the output of the following C code?#include <stdio.h> struct Country { int code = 12; char name[20]; }; void main() { struct Country c; c.code = 15; printf("England"); } |
A. | Compilation Error |
B. | Nothing |
C. | England |
D. | 15 |
E. | None of these |
Answer» B. Nothing | |
58. |
What will be the output of the following C code?#include <stdio.h> typedef struct p *q; int main() { struct p { int num1; char num2; q ptr; }; struct p p = {50, 55, &p}; printf("%d n", p.ptr->x); return 0; } |
A. | 50 |
B. | 55 |
C. | Compilation Error |
D. | Garbage value |
E. | None of these |
Answer» D. Garbage value | |
59. |
What will be the output of the following C code?#include <stdio.h> typedef struct p *q; struct p { int n1; char n2; q ptr; }; typedef struct p *q; int main() { struct p p = {101, 202, &p}; printf("%d n", p.ptr->n1); return 0; } |
A. | Compilation Error |
B. | Garbage value |
C. | 101 |
D. | 202 |
E. | None of these |
Answer» D. 202 | |
60. |
What will be the output of the following C code?#include <stdio.h> struct Number { int n1; int n2; }; void function(struct Number*); int main() { struct Number num1[] = {15, 25, 35, 45}; function(num1); } void function(struct Number num2[]) { printf("%d n", num2->n1); } |
A. | 15 |
B. | 25 |
C. | 35 |
D. | 45 |
E. | None of these |
Answer» B. 25 | |
61. |
What will be the output of the following C code? #include <stdio.h> struct Option { int a; int b; }; void fun(struct Option*); int main() { struct Option opt1[] = {13, 23, 33, 43}; fun(opt1); } void fun(struct Option opt2[]) { printf("%d n", opt2[1].a); } |
A. | 13 |
B. | 23 |
C. | 33 |
D. | 43 |
E. | None of these |
Answer» D. 43 | |
62. |
What will be the output of the following C code?#include <stdio.h> struct City { }; void main() { struct City c[2]; printf("%d", sizeof(c)); } |
A. | 0 |
B. | 2 |
C. | 4 |
D. | 8 |
E. | None of these |
Answer» B. 2 | |
63. |
What will be the output of the following C code?#include <stdio.h> struct student { char *name; }; void main() { struct student s1[2], s2[2]; s1[1] = s1[0] = "Ajit Kumar Gupta"; printf("%s %s", s1[0].name, s1[1].name); } |
A. | Compilation Error |
B. | Garbage value |
C. | Ajit Kumar Gupta |
D. | Undefined behaviour |
E. | None of these |
Answer» B. Garbage value | |
64. |
What will be the output of the following C code?#include <stdio.h> struct Worker { char *name; }; struct Worker w1[2], w2[2]; void main() { w1[0].name = "Imaraj"; w1[1] = w1[0]; w2 = w1; printf("%s%s", w2[0].name, w2[1].name); } |
A. | Imaraj |
B. | Compilation Error |
C. | Garbage value |
D. | Nothing |
E. | None of these |
Answer» C. Garbage value | |
65. |
What will be the output of the following C code?#include <stdio.h> struct Condition { int n1; char n2; }; int main() { struct Condition con1[] = {11, 91, 31, 14, 15, 16}; struct Condition *ptr1 = con1; int n1 = (sizeof(con1) / sizeof(ptr1)); if (n1 == 1) printf("%d n", ptr1->n1); else printf("False n"); } |
A. | False |
B. | Compilation Error |
C. | Garbage value |
D. | Nothing |
E. | None of these |
Answer» B. Compilation Error | |
66. |
What will be the output of the following C code?#include <stdio.h> struct Company { int c1; char c2; }; int main() { struct Company comp1[] = {10, 91, 30, 90, 52, 95}; struct Company *ptr1 = comp1; int c1 = (sizeof(comp1) / 3); if (c1 == sizeof(int) + sizeof(char)) printf("%d n", ptr1->c1); else printf("Interview Mania"); } |
A. | Compilation Error |
B. | Garbage value |
C. | Interview Mania |
D. | Nothing |
E. | None of these |
Answer» D. Nothing | |
67. |
What will be the output of the following C code?#include <stdio.h> struct alphabet { char *ch; }; void main() { struct alphabet alp[2]; printf("%d", sizeof(alp)); } |
A. | 16 |
B. | 8 |
C. | 4 |
D. | 2 |
E. | None of these |
Answer» B. 8 | |
68. |
What is the output of this C code?#include <stdio.h> struct Employee { char *name; }; void main() { struct Employee emp1, emp2; emp1.name = "Ajit"; emp2 = emp1; printf("%s %s", emp1.name, emp2.name); } |
A. | Ajit Ajit |
B. | Garbage value |
C. | Compilation Error |
D. | Nothing |
E. | None of these |
Answer» B. Garbage value | |
69. |
What will be the output of the following C code according to C99 standard?#include <stdio.h> struct stru { int i; char ch; float flt; }; int main() { struct stru Res = {.ch = 333}; printf("%f n", Res.flt); } |
A. | 333.000000 |
B. | Compilation Error |
C. | Garbage value |
D. | 0.000000 |
E. | None of these |
Answer» E. None of these | |
70. |
What will be the output of the following C code according to C99 standard? #include <stdio.h> struct S { int i; char ch; float flt; }; int main() { struct S R = {.ch = 45, .i = 11, 31}; printf("%f n", R.flt); } |
A. | 31.000000 |
B. | Compilation Error |
C. | Garbage value |
D. | Undefined behabiour |
E. | 0.000000 |
Answer» F. | |
71. |
What will be the output of the following C code according to C99 standard?#include <stdio.h> struct stru { int m; char n; float t; }; int main() { struct stru R = {.n = 99, .t = 13, .m = 21}; printf("%f n", R.t); } |
A. | Compilation Error |
B. | 13.000000 |
C. | Garbage value |
D. | Undefined behaviour |
E. | None of these |
Answer» C. Garbage value | |
72. |
Which of the following structure declaration is incorrect ? |
A. | <pre class="prettyprint lang-c">struct aa<br>{<br> int a;<br> float b;<br>};<br></pre> |
B. | <pre class="prettyprint lang-c">struct aa<br>{<br> int a;<br> float b;<br> struct aa var;<br>};<br></pre> |
C. | <pre class="prettyprint lang-c">struct aa<br>{<br> int a;<br> float b;<br> struct aa *var;<br>};<br></pre> |
D. | <pre class="prettyprint lang-c">struct aa<br>{<br> int a;<br> float b;<br> struct aa **var;<br>};<br></pre> |
Answer» C. <pre class="prettyprint lang-c">struct aa<br>{<br> int a;<br> float b;<br> struct aa *var;<br>};<br></pre> | |
73. |
Which of the following is the correct output fot the program given below? |
A. | 0 0.000000 |
B. | Garbage values |
C. | Error |
D. | None of the above |
Answer» B. Garbage values | |
74. |
Which of the following structure declaration is correct ? |
A. | <pre class="prettyprint lang-c">struct employ<br>{<br> char name[10];<br> float salary;<br> int workingdays;<br>};<br></pre> |
B. | <pre class="prettyprint lang-c">struct employ<br>{<br> char name[10];<br> float salary;<br> int workingdays;<br>}<br></pre> |
C. | <pre class="prettyprint lang-c">struct employ<br>{<br> char name[10]<br> float salary<br> int workingdays<br>};<br></pre> |
D. | All of the above. |
Answer» B. <pre class="prettyprint lang-c">struct employ<br>{<br> char name[10];<br> float salary;<br> int workingdays;<br>}<br></pre> | |
75. |
Which of the following will stop the loop at the last node of a linked list in the following C code snippet? |
A. | <pre class="prettyprint lang-c">while (p->next != NULL)<br> {<br> p = p->next;<br> }<br></pre> |
B. | <pre class="prettyprint lang-c">while (1)<br> {<br> p = p->next;<br> if (p == NULL)<br> break;<br> }<br></pre> |
C. | <pre class="prettyprint lang-c">while (p != NULL)<br> {<br> p = p->next;<br> }<br></pre> |
D. | All of above |
E. | None of these |
Answer» B. <pre class="prettyprint lang-c">while (1)<br> {<br> p = p->next;<br> if (p == NULL)<br> break;<br> }<br></pre> | |
76. |
Presence of code like s.t.b = 100 indicates __________. |
A. | double data type |
B. | Syntax Error |
C. | Structure |
D. | All of above |
E. | None of these |
Answer» D. All of above | |
77. |
Presence of loop in a linked list can be tested by ________. |
A. | Comparing the address of nodes by address of every other node |
B. | Comparing the the value stored in a node by a value in every other node |
C. | Traveling the list, if NULL is encountered no loop exists |
D. | All of above |
E. | None of these |
Answer» B. Comparing the the value stored in a node by a value in every other node | |
78. |
What will be the output of the following C code according to C99 standard? |
A. | Compilation Error |
B. | 13.000000 |
C. | Garbage value |
D. | Undefined behaviour |
E. | None of these |
Answer» C. Garbage value | |
79. |
The number of distinct nodes the following struct declaration can point to is _____________. |
A. | 3 |
B. | 2 |
C. | 1 |
D. | All of above |
E. | None of these |
Answer» E. None of these | |
80. |
How many bytes in memory taken by the following C structure? |
A. | Multiple of word size |
B. | Depends on the platform |
C. | integer size+character size |
D. | Multiple of integer size |
E. | None of these |
Answer» E. None of these | |
81. |
Which option is not possible for the following function call? |
A. | Individual member can be passed by reference in a function |
B. | Individual member s address can be displayed in structure |
C. | Compiler can access entire structure from the function |
D. | All of above |
E. | None of these |
Answer» D. All of above | |
82. |
Can the following C code be compiled successfully? |
A. | Depends on the standard |
B. | No |
C. | Depends on the platform |
D. | Yes |
E. | None of these |
Answer» E. None of these | |
83. |
Which of the following structure declaration doesn t require pass-by-reference? |
A. | <pre class="prettyprint lang-c">struct temp{int a;};<br> main(){}<br> struct temp s;<br></pre> |
B. | <pre class="prettyprint lang-c">struct{int a;}s;<br> main(){}<br></pre> |
C. | <pre class="prettyprint lang-c">struct temp{int a;};<br> main(){<br> struct temp s;<br> }<br></pre> |
D. | All of above |
E. | None of these |
Answer» F. | |
84. |
Which of the following is an incorrect syntax to pass by reference a member of a structure in a function? |
A. | func(&(e).num); |
B. | func(&(e.num)); |
C. | func(&e.num); |
D. | All of above |
E. | None of these |
Answer» F. | |
85. |
The correct syntax to access the member of the ith structure in the array of structures is? |
A. | sct[j].n; |
B. | sct.n[j]; |
C. | sct.[j].n; |
D. | sct.n.[j]; |
E. | None of these |
Answer» B. sct.n[j]; | |
86. |
Which of the following is an incorrect syntax for pointer to structure? |
A. | (*ptr_struct).n = 110; |
B. | ptr_struct->n = 110; |
C. | *ptr_struct.n = 110; |
D. | Both (*ptr_struct).n = 110; and *ptr_struct.n = 110; |
E. | None of these |
Answer» D. Both (*ptr_struct).n = 110; and *ptr_struct.n = 110; | |
87. |
What will be the output of the following C code? (Assuming size of int be 4) |
A. | 16 |
B. | 12 |
C. | 4 |
D. | Compilation Error |
E. | None of these |
Answer» C. 4 | |
88. |
What is the correct syntax to declare a function fun() which receives an array of structure in function? |
A. | void fun(struct *num[]); |
B. | void fun(struct num); |
C. | void fun(struct *num); |
D. | All of above |
E. | None of these |
Answer» D. All of above | |
89. |
Comment on the output of the following C code. |
A. | No Compile time error, generates an array of structure of size 9 |
B. | Compile time error, illegal declaration of a multidimensional array |
C. | Compile time error, illegal assignment to members of structure |
D. | No Compile time error, generates an array of structure of size 3 |
E. | None of these |
Answer» E. None of these | |
90. |
Which of the following structure declaration will throw an error? |
A. | <pre class="prettyprint lang-c">struct temp{};<br> struct temp s;<br> main(){}<br></pre> |
B. | <pre class="prettyprint lang-c">struct temp s;<br> struct temp{};<br> main(){}<br></pre> |
C. | <pre class="prettyprint lang-c">struct temp{}s;<br> main(){}<br></pre> |
D. | All of above |
E. | None of these |
Answer» F. | |
91. |
User-defined data type can be derived by___________. |
A. | enum |
B. | typedef |
C. | struct |
D. | All of above |
E. | None of these |
Answer» E. None of these | |