

MCQOPTIONS
Saved Bookmarks
This section includes 202 Mcqs, each offering curated multiple-choice questions to sharpen your C Programming knowledge and support exam preparation. Choose a topic below to get started.
101. |
What will be the output of the following C code?#include <stdio.h> void main() { int arr[5] = {101, 201, 301, 401, 501}; int *q1 = arr; int *q2 = &q1; printf("%d", (**q2)); } |
A. | Garbage value |
B. | Compilation Error |
C. | 101 |
D. | 102 |
E. | Same memory address |
Answer» C. 101 | |
102. |
What will be the output of the following C code?#include <stdio.h> void main() { int array[4] = {11, 12, 13, 14}; int *ptr1 = array; int *ptr2 = &ptr1; printf("%d", (**ptr2)); } |
A. | 11 |
B. | 12 |
C. | 13 |
D. | 14 |
E. | Compilation Error |
Answer» F. | |
103. |
What will be the output of the following C code? #include <stdio.h> void main() { int num = 14; int *ptr1 = &num; int **ptr2 = &ptr1; **ptr2 = 16; printf("%d n", num); } |
A. | Compilation Error |
B. | 14 |
C. | Garbage value |
D. | 16 |
E. | None of these |
Answer» E. None of these | |
104. |
What will be the output of the following C code?#include >stdio.h< void main() { int n = 15; int *ptr1 = &n; int **ptr2 = &ptr1; printf("%d %d %d n", n, *ptr1, **ptr1); } |
A. | Compilation Error |
B. | 15, 15, 15 |
C. | Garbage value, Garbage value, Garbage value |
D. | Garbage value, 15, 15 |
E. | None of these |
Answer» B. 15, 15, 15 | |
105. |
What will be the output of the following C code?#include <stdio.h> void main() { int i = 51; int *ptr1 = &i; int **ptr2 = &ptr1; printf("%d %d %d n", i, *ptr1, **ptr2); } |
A. | 51, 51, Garbage value |
B. | Garbage value, Garbage value, Garbage value |
C. | 51, 51, 51 |
D. | Compilation Error |
E. | None of these |
Answer» D. Compilation Error | |
106. |
What will be the output of the following C code?#include <stdio.h> void main() { char str[] = "WELCOME"; str++; printf("%c n", *str); } |
A. | Compilation Error |
B. | W |
C. | L |
D. | Garbage value |
E. | None of these |
Answer» B. W | |
107. |
What will be the output of the following C code?#include <stdio.h> void main() { char *str = "SUJIT"; char *ptr = str * 5; printf("%c t%c", *ptr, str[3]); } |
A. | S I |
B. | I S |
C. | Garbage value |
D. | Compilation Error |
E. | None of these |
Answer» E. None of these | |
108. |
What will be the output of the following C code?#include <stdio.h> void main() { char *str = "InterviewMania"; char *ntr = "Mania"; char *ptr = str + ntr; printf("%c t%c", *ptr, str[1]); } |
A. | InterviewMania |
B. | Mania |
C. | Compilation Error |
D. | I M |
E. | None of these |
Answer» D. I M | |
109. |
Is the below declaration legal?int* ((*N)())[12]; |
A. | Undefined behaviour |
B. | True |
C. | False |
D. | Depends on the standard |
E. | None of these |
Answer» D. Depends on the standard | |
110. |
What will be the output of the following C code?#include <stdio.h> void main() { struct Employee { int Id; char Name[35]; }; struct Employee emp; emp.Id = 15; printf("%d", emp.Id); } |
A. | compilation Error |
B. | Garbage value |
C. | 15 |
D. | Nothing |
E. | None of these |
Answer» D. Nothing | |
111. |
What will be the output of the following C code?#include <stdio.h> struct clothes { int size; char Brand_name[24]; }; void main() { clothes c; c.size = 36; printf("Peter England"); } |
A. | Compilation Error |
B. | Garbage value |
C. | Peter England |
D. | Nothing |
E. | None of these |
Answer» B. Garbage value | |
112. |
What will be the output of the following C code?#include <stdio.h> struct car { int car_no = 12; char car_name[25]; }; void main() { struct car c; c.car_no = 10; printf("Audi"); } |
A. | 10 |
B. | Compilation Error |
C. | Audi |
D. | Garbage value |
E. | None of these |
Answer» C. Audi | |
113. |
What will be the output of the following C code?#include <stdio.h> struct student { int roll_no; char Name[35]; } void main() { struct student stu; stu.roll_no = 10; printf("Ajit Kumar Gupta"); } |
A. | Nothing |
B. | Ajit Kumar Gupta |
C. | 10 |
D. | Garbage value |
E. | Compilation Error |
Answer» F. | |
114. |
What will be the output of the following C code? #include <stdio.h> int main() { int num[5] = {11, 21, 31, 41, 51}; int ptr[5]; ptr = num; printf("%d n", ptr[2]); } |
A. | Undefined behaviour |
B. | Garbage value |
C. | Compilation Error |
D. | 51 |
E. | None of these |
Answer» D. 51 | |
115. |
Comment on the following pointer declaration.int *p, n; |
A. | p and n both are not pointers to integer |
B. | p is a pointer to integer, n may or may not be |
C. | p and n, both are pointers to integer |
D. | p is a pointer to integer, n is not |
E. | None of these |
Answer» E. None of these | |
116. |
What will be the output of the following C code? #include <stdio.h> int *fun(); int main() { int *ptr = fun(); printf("%d n", *ptr); } int *fun() { int n = 12; return &n; } |
A. | Segmentation fault |
B. | Undefined behaviour |
C. | Compilation Error |
D. | 12 |
E. | None of these |
Answer» B. Undefined behaviour | |
117. |
What will be the output of the following C code?#include <stdio.h> int *fun(); int main() { int *ptr = fun(); printf("%d n", *ptr); } int *fun() { int *p = (int*)malloc(sizeof(int)); *p = 11; return p; } |
A. | Compilation Error |
B. | 11 |
C. | Undefined behaviour |
D. | Segmentation fault/runtime crash since pointer to local variable is returned |
E. | None of these |
Answer» C. Undefined behaviour | |
118. |
What will be the output of the following C code? #include <stdio.h> int main() { int num = 110; void *ptr = &num; printf("%f n", *(float*)ptr); return 0; } |
A. | 110 |
B. | Undefined behaviour |
C. | Garbage value |
D. | Compilation Error |
E. | 0.000000 |
Answer» F. | |
119. |
What will be the output of the following C code?#include <stdio.h> int main() { int n = 12; void *ptr = &n; printf("%d n", (int)*ptr); return 0; } |
A. | Compilation Error |
B. | Garbage value |
C. | 12 |
D. | Nothing |
E. | None of these |
Answer» B. Garbage value | |
120. |
What will be the output of the following C code?#include <stdio.h> void fun(int*); int main() { int num = 10; fun((&num)++); } void fun(int *ptr) { printf("%d n", *ptr); } |
A. | Compilation Error |
B. | 113 |
C. | Garbage value |
D. | Runtime Error |
E. | None of these |
Answer» B. 113 | |
121. |
What will be the output of the following C code?#include <stdio.h> void main() { int var = 101; int *p = &var; printf("%d n", *p); } |
A. | 101 |
B. | Compilation Error |
C. | Address of var |
D. | Garbage value |
E. | None of these |
Answer» B. Compilation Error | |
122. |
What will be the output of the following C code?#include <stdio.h> void main() { int var = 10; int *p = &15; printf("%p n", p); } |
A. | 10 |
B. | 15 |
C. | Garbage value |
D. | Compilation Error |
E. | None of these |
Answer» E. None of these | |
123. |
What will be the output of the following C code?#include <stdio.h> void main() { int n = 0; int *p = &n; printf("%p n", p); p++; printf("%p n ", p); } |
A. | Compilation Error |
B. | Different memory address |
C. | Garbage value |
D. | Same memory address |
E. | None of these |
Answer» C. Garbage value | |
124. |
What will be the output of the following C code?#include <stdio.h> int n = 0; void main() { int *const p = &n; printf("%p n", p); p++; printf("%p n ", p); } |
A. | Same memory address |
B. | Compilation Error |
C. | Different memory address |
D. | Garbage value |
E. | None of these |
Answer» C. Different memory address | |
125. |
What will be the output of the following C code? #include <stdio.h> int num = 0; void main() { int *p = &num; printf("%p n", p); num++; printf("%p n ", p); } |
A. | Compilation Error |
B. | Same memory address |
C. | Different memory address |
D. | Varies |
E. | None of these |
Answer» C. Different memory address | |
126. |
What will be the output of the following C code? #include <stdio.h> int main() { int num = 12; int *ptr = &num; foo(&ptr); printf("%d ", *ptr); printf("%d ", *ptr); } void foo(int **const ptr) { int k = 13; *ptr = &k; printf("%d ", **ptr); } |
A. | Undefined-value |
B. | 13 13 13 |
C. | Compilation Error |
D. | Segmentation fault/code-crash |
E. | None of these |
Answer» C. Compilation Error | |
127. |
What will be the output of the following C code?#include <stdio.h> void fun(int m, int n) { int temp = m; m = n; n = temp; } void main() { int s = 16, t = 15; fun(s, t); printf("%d %d n", s, t); } |
A. | 16 16 |
B. | 15 15 |
C. | 15 16 |
D. | 16 15 |
E. | Compilation Error |
Answer» E. Compilation Error | |
128. |
What will be the output of the following C code?#include <stdio.h> void fun(int *ptr) { int k = 0; for(k = 0; k < 4; k++) printf("%d ", ptr[k]); } void main() { int n[5] = {16, 15, 13, 21}; fun(&n); } |
A. | Compilation Error |
B. | 16 15 13 21 |
C. | 21 13 15 16 |
D. | Runtime Error |
E. | None of these |
Answer» C. 21 13 15 16 | |
129. |
What will be the output of the following C code?#include <stdio.h> void fun(int *ptr1, int *ptr2) { int temp = *ptr1; *ptr1 = *ptr2; *ptr2 = temp; } void main() { int m = 10, n = 12; fun(&m, &n); printf("%d %d n", m, n); } |
A. | Compilation Error |
B. | 10 12 |
C. | 12 10 |
D. | Garbage value |
E. | None of these |
Answer» D. Garbage value | |
130. |
What will be the output of the following C code?#include <stdio.h> void main() { char *ptr1= "Interview Mania"; char *ptr2 = ptr1; printf("%c %c", ptr2[0], ptr1[10]); } |
A. | Interview Mania |
B. | Compilation Error |
C. | I M |
D. | M I |
E. | None of these |
Answer» D. M I | |
131. |
What will be the output of the following C code? #include <stdio.h> void main() { char *ptr1 = "Interview Mania"; char *ptr2 = ptr1; printf("%p %p", ptr2, ptr1); } |
A. | Compilation Error |
B. | Same memory address is printed |
C. | Different memory address is printed |
D. | Nothing |
E. | None of these |
Answer» C. Different memory address is printed | |
132. |
What will be the output of the following C code?#include <stdio.h> void main() { int arr[4] = {11, 12, 13, 14}; int *ptr = arr; printf("%p t%p", ptr, arr); } |
A. | Different memory address is printed |
B. | Compilation Error |
C. | Nothing |
D. | Same memory address is printed |
E. | None of these |
Answer» E. None of these | |
133. |
What will be the output of the following C code?#include <stdio.h> void function(int m, int n) { printf("%d %d n", m, n); } void main() { int s = 16, t = 15; function(s); } |
A. | Garbage value |
B. | Runtime Error |
C. | 16 15 |
D. | 15 16 |
E. | Compilation Error |
Answer» F. | |
134. |
What will be the output of the following C code?#include <stdio.h> int main() { int A[5] = {10, 20, 30, 40, 50}; int *ptr = A + 2; printf("%d %d n", ptr[-1], A[*ptr]); } |
A. | 20 0 |
B. | Compilation Error |
C. | 20 Garbage value |
D. | 0 20 |
E. | None of these |
Answer» B. Compilation Error | |
135. |
What will be the output of the following C code? #include <stdio.h> int main() { int array[5] = {11, 12, 13, 14, 15}; int *ptr = array + 7; printf("%d n", ptr[-3]); } |
A. | 11 |
B. | 12 |
C. | 13 |
D. | 14 |
E. | 15 |
Answer» F. | |
136. |
What are the elements present in the array of the following C code?int num[4] = {10}; |
A. | 10, 10, 10, 10 |
B. | 0, 0, 0, 0 |
C. | 10, 0, 0, 0 |
D. | 0, garbage value, garbage value, garbage value |
E. | 10, garbage value, garbage value, garbage value |
Answer» D. 0, garbage value, garbage value, garbage value | |
137. |
What will be the output of the following C code?#include <stdio.h> int main() { const int num[5] = {11, 21, 31, 41, 51}; int *ptr; ptr = num + 3; *ptr = 50; printf("%d n", num[3]); } |
A. | 11 |
B. | 21 |
C. | 31 |
D. | 51 |
E. | 50 |
Answer» F. | |
138. |
What will be the output of the following C code?#include <stdio.h> int main() { int num[6] = {6, 7, 8, 9, 10}; printf("%d n", *num); } |
A. | 10 |
B. | 9 |
C. | 8 |
D. | 7 |
E. | 6 |
Answer» F. | |
139. |
What will be the output of the following C code?#include <stdio.h> void fun( int[] ); int main() { int array[5] = {10, 20, 30, 40, 50}; fun(array); printf("%d ", array[2]); } void fun(int ptr[5]) { int n = 100; ptr = &n; printf("%d ", ptr[0]); } |
A. | 100 100 |
B. | 10 100 |
C. | 100 10 |
D. | 30 100 |
E. | 100 30 |
Answer» F. | |
140. |
What will be the output of the following C code?#include <stdio.h> void main() { char *str= "WATCH"; char *ptr = str; printf("%c %c", 1[ptr], str[1]); } |
A. | A A |
B. | WATCH |
C. | Compilation Error |
D. | Garbage value |
E. | None of these |
Answer» B. WATCH | |
141. |
What will be the output of the following C code? #include <stdio.h> void main() { char *str= "WELCOME"; char *ptr = str; printf("%c %c", *(ptr + 2), str[0]); } |
A. | WELCOME |
B. | Compilation Error |
C. | L W |
D. | W L |
E. | None of these |
Answer» D. W L | |
142. |
Comment on the following C statement.const int *p; |
A. | You can change the pointer as well as the value pointed by it |
B. | You May or maynot change the value pointed by p |
C. | You cannot change the pointer p itself |
D. | You cannot change the value pointed by p |
E. | None of these |
Answer» E. None of these | |
143. |
What will be the output of the following C code?#include <stdio.h> int main() { int *p, n = 15; p = &n; *p += 10; printf("%d, %d n", *p, n); } |
A. | 15 |
B. | 10 |
C. | 25, 25 |
D. | 15 10 |
E. | None of these |
Answer» D. 15 10 | |
144. |
What will be the output of the following C code?#include <stdio.h> int main() { int n = 101; int *ptr = &n; fun(&ptr); printf("%d ", *ptr); } void fun(int *const *ptr) { int k = 100; *ptr = &k; printf("%d ", **ptr); } |
A. | 100 100 |
B. | 101 100 |
C. | Garbage value |
D. | Compilation Error |
E. | None of these |
Answer» E. None of these | |
145. |
What will be the output of the following C code? #include <stdio.h> int main() { int n = 58, *ptr = &n; function(&ptr); printf("%d ", *ptr); return 0; } void function(int **ptr) { int k = 12; *ptr = &k; printf("%d ", **ptr); } |
A. | Undefined behaviour |
B. | 58 |
C. | Segmentation fault/code crash |
D. | 12 12 |
E. | None of these |
Answer» E. None of these | |
146. |
What will be the output of the following C code?#include <stdio.h> void fun(int*); int main() { int n = 14, *ptr = &n; fun(ptr++); } void fun(int *ptr) { printf("%d n", *ptr); } |
A. | 0.000000 |
B. | Compilation Error |
C. | 14.000000 |
D. | Runtime Error |
E. | None of these |
Answer» B. Compilation Error | |
147. |
What will be the output of the following C code?#include <stdio.h> int main() { int num = 45, *ptr = &num; function(&num); printf("%d ", *ptr); } void function(int *ptr) { int L = 20; ptr = &L; printf("%d ", *ptr); } |
A. | 20 45 |
B. | 20 |
C. | 45 |
D. | 45 20 |
E. | Compilation Error |
Answer» B. 20 | |
148. |
What will be the output of the following C code?#include <stdio.h> void fun(int*); int main() { int n = 101, *ptr = &n; fun(ptr++); } void fun(int *ptr) { printf("%d n", *ptr); } |
A. | Garbage value |
B. | 101 |
C. | Segmentation fault |
D. | Compilation Error |
E. | None of these |
Answer» C. Segmentation fault | |
149. |
What will be the output of the program if the size of pointer is 4-bytes? #include int main() { printf("%d, %d\n", sizeof(NULL), sizeof(")); return 0; } |
A. | 2, 1 |
B. | 2, 2 |
C. | 4, 1 |
D. | 4, 2 |
Answer» D. 4, 2 | |
150. |
What will be the output of the program ?_x000D_ #include_x000D_ _x000D_ void fun(void *p);_x000D_ int i;_x000D_ _x000D_ int main()_x000D_ {_x000D_ void *vptr;_x000D_ vptr = &i;_x000D_ fun(vptr);_x000D_ return 0;_x000D_ }_x000D_ void fun(void *p)_x000D_ {_x000D_ int **q;_x000D_ q = (int**)&p;_x000D_ printf("%d\n", **q);_x000D_ } |
A. | Error: cannot convert from void** to int** |
B. | Garbage value |
C. | 0 |
D. | No output |
Answer» D. No output | |