

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.
151. |
What will be the output of the program If the integer is 4bytes long?_x000D_ #include_x000D_ _x000D_ int main()_x000D_ {_x000D_ int ***r, **q, *p, i=8;_x000D_ p = &i;_x000D_ q = &p;_x000D_ r = &q;_x000D_ printf("%d, %d, %d\n", *p, **q, ***r);_x000D_ return 0;_x000D_ } |
A. | 8, 8, 8 |
B. | 4000, 4002, 4004 |
C. | 4000, 4004, 4008 |
D. | 4000, 4008, 4016 |
Answer» B. 4000, 4002, 4004 | |
152. |
What will be the output of the program ? #include int main() { char *p; p="hello"; printf("%s\n", *&*&p); return 0; } |
A. | llo |
B. | hello |
C. | ello |
D. | h |
Answer» C. ello | |
153. |
What will be the output of the program assuming that the array begins at location 1002?_x000D_ #include_x000D_ _x000D_ int main()_x000D_ {_x000D_ int a[2][3][4] = { {1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 1, 2}, _x000D_ {2, 1, 4, 7, 6, 7, 8, 9, 0, 0, 0, 0} };_x000D_ printf("%u, %u, %u, %d\n", a, *a, **a, ***a);_x000D_ return 0;_x000D_ } |
A. | 1002, 2004, 4008, 2 |
B. | 2004, 4008, 8016, 1 |
C. | 1002, 1002, 1002, 1 |
D. | Error |
Answer» D. Error | |
154. |
What will be the output of the program?_x000D_ #include_x000D_ _x000D_ int main()_x000D_ {_x000D_ int arr[3] = {2, 3, 4};_x000D_ char *p;_x000D_ p = arr;_x000D_ p = (char*)((int*)(p));_x000D_ printf("%d, ", *p);_x000D_ p = (int*)(p+1);_x000D_ printf("%d", *p);_x000D_ return 0;_x000D_ } |
A. | 2, 3 |
B. | 2, 0 |
C. | 2, Garbage value |
D. | 0, 0 |
Answer» C. 2, Garbage value | |
155. |
What will be the output of the program?_x000D_ #include_x000D_ _x000D_ int main()_x000D_ {_x000D_ int arr[2][2][2] = {10, 2, 3, 4, 5, 6, 7, 8};_x000D_ int *p, *q;_x000D_ p = &arr[1][1][1];_x000D_ q = (int*) arr;_x000D_ printf("%d, %d\n", *p, *q);_x000D_ return 0;_x000D_ } |
A. | 8, 10 |
B. | 10, 2 |
C. | 8, 1 |
D. | Garbage values |
Answer» B. 10, 2 | |
156. |
What will be the output of the program assuming that the array begins at the location 1002 and size of an integer is 4 bytes?_x000D_ #include_x000D_ _x000D_ int main()_x000D_ {_x000D_ int a[3][4] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };_x000D_ printf("%u, %u, %u\n", a[0]+1, *(a[0]+1), *(*(a+0)+1));_x000D_ return 0;_x000D_ } |
A. | 448, 4, 4 |
B. | 520, 2, 2 |
C. | 1006, 2, 2 |
D. | Error |
Answer» D. Error | |
157. |
What will be the output of the program ? #include int *check(static int, static int); int main() { int *c; c = check(10, 20); printf("%d\n", c); return 0; } int *check(static int i, static int j) { int *p, *q; p = &i; q = &j; if(i >= 45) return (p); else return (q); } |
A. | 10 |
B. | 20 |
C. | Error: Non portable pointer conversion |
D. | Error: cannot use static for function parameters |
Answer» E. | |
158. |
What will be the output of the program ? #include int main() { char *p; p="hello"; printf("%s\n", *&*&p); return 0; } |
A. | llo |
B. | hello |
C. | ello |
D. | h |
Answer» C. ello | |
159. |
What will be the output of the program ? #include power(int**); int main() { int a=5, *aa; /* Address of 'a' is 1000 */ aa = &a; a = power(&aa); printf("%d\n", a); return 0; } power(int **ptr) { int b; b = **ptr***ptr; return (b); } |
A. | 5 |
B. | 25 |
C. | 125 |
D. | Garbage value |
Answer» C. 125 | |
160. |
What will be the output of the program? #include int main() { int arr[3] = {2, 3, 4}; char *p; p = arr; p = (char*)((int*)(p)); printf("%d, ", *p); p = (int*)(p+1); printf("%d", *p); return 0; } |
A. | 2, 3 |
B. | 2, 0 |
C. | 2, Garbage value |
D. | 0, 0 |
Answer» C. 2, Garbage value | |
161. |
In the following program add a statement in the function fact() such that the factorial gets stored in j. #include void fact(int*); int main() { int i=5; fact(&i); printf("%d\n", i); return 0; } void fact(int *j) { static int s=1; if(*j!=0) { s = s**j; *j = *j-1; fact(j); /* Add a statement here */ } } |
A. | j=s; |
B. | *j=s; |
C. | *j=&s; |
D. | &j=s; |
Answer» C. *j=&s; | |
162. |
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 | |
163. |
What will be the output of the program ? #include int main() { int i, a[] = {2, 4, 6, 8, 10}; change(a, 5); for(i=0; i |
A. | 7, 9, 11, 13, 15 |
B. | 2, 15, 6, 8, 10 |
C. | 2 4 6 8 10 |
D. | 3, 1, -1, -3, -5 |
Answer» C. 2 4 6 8 10 | |
164. |
Which statement will you add to the following program to ensure that the program outputs "IndiaBIX" on execution? #include int main() { char s[] = "IndiaBIX"; char t[25]; char *ps, *pt; ps = s; pt = t; while(*ps) *pt++ = *ps++; /* Add a statement here */ printf("%s\n", t); return 0; } |
A. | *pt=''; |
B. | pt='\0'; |
C. | pt='\n'; |
D. | *pt='\0'; |
Answer» E. | |
165. |
What will be the output of the program ? #include int main() { char *str; str = "%s"; printf(str, "K\n"); return 0; } |
A. | Error |
B. | No output |
C. | K |
D. | %s |
Answer» D. %s | |
166. |
What will be the output of the program assuming that the array begins at the location 1002 and size of an integer is 4 bytes? #include int main() { int a[3][4] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }; printf("%u, %u, %u\n", a[0]+1, *(a[0]+1), *(*(a+0)+1)); return 0; } |
A. | 448, 4, 4 |
B. | 520, 2, 2 |
C. | 1006, 2, 2 |
D. | Error |
Answer» D. Error | |
167. |
What will be the output of the program ? #include int main() { char *str; str = "%d\n"; str++; str++; printf(str-2, 300); return 0; } |
A. | No output |
B. | 30 |
C. | 3 |
D. | 300 |
Answer» E. | |
168. |
What will be the output of the program assuming that the array begins at location 1002? #include int main() { int a[2][3][4] = { {1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 1, 2}, {2, 1, 4, 7, 6, 7, 8, 9, 0, 0, 0, 0} }; printf("%u, %u, %u, %d\n", a, *a, **a, ***a); return 0; } |
A. | 1002, 2004, 4008, 2 |
B. | 2004, 4008, 8016, 1 |
C. | 1002, 1002, 1002, 1 |
D. | Error |
Answer» D. Error | |
169. |
What will be the output of the program ? #include int main() { printf("%c\n", 7["IndiaBIX"]); return 0; } |
A. | Error: in printf |
B. | Nothing will print |
C. | print "X" of IndiaBIX |
D. | print "7" |
Answer» D. print "7" | |
170. |
What will be the output of the program ? #include int main() { void *vp; char ch=74, *cp="JACK"; int j=65; vp=&ch; printf("%c", *(char*)vp); vp=&j; printf("%c", *(int*)vp); vp=cp; printf("%s", (char*)vp+2); return 0; } |
A. | JCK |
B. | J65K |
C. | JAK |
D. | JACK |
Answer» E. | |
171. |
If the size of integer is 4bytes, What will be the output of the program? #include int main() { int arr[] = {12, 13, 14, 15, 16}; printf("%d, %d, %d\n", sizeof(arr), sizeof(*arr), sizeof(arr[0])); return 0; } |
A. | 10, 2, 4 |
B. | 20, 4, 4 |
C. | 16, 2, 2 |
D. | 20, 2, 2 |
Answer» C. 16, 2, 2 | |
172. |
What will be the output of the program ? #include int main() { char str1[] = "India"; char str2[] = "BIX"; char *s1 = str1, *s2=str2; while(*s1++ = *s2++) printf("%s", str1); printf("\n"); return 0; } |
A. | IndiaBIX |
B. | BndiaBIdiaBIXia |
C. | India |
D. | (null) |
Answer» C. India | |
173. |
What will be the output of the program? #include int main() { int arr[2][2][2] = {10, 2, 3, 4, 5, 6, 7, 8}; int *p, *q; p = &arr[1][1][1]; q = (int*) arr; printf("%d, %d\n", *p, *q); return 0; } |
A. | 8, 10 |
B. | 10, 2 |
C. | 8, 1 |
D. | Garbage values |
Answer» B. 10, 2 | |
174. |
Will the program compile in Turbo C? #include int main() { int a=10, *j; void *k; j=k=&a; j++; k++; printf("%u %u\n", j, k); return 0; } |
A. | Yes |
B. | No |
Answer» C. | |
175. |
What will be the output of the program If the integer is 4bytes long? #include int main() { int ***r, **q, *p, i=8; p = &i; q = &p; r = &q; printf("%d, %d, %d\n", *p, **q, ***r); return 0; } |
A. | 8, 8, 8 |
B. | 4000, 4002, 4004 |
C. | 4000, 4004, 4008 |
D. | 4000, 4008, 4016 |
Answer» B. 4000, 4002, 4004 | |
176. |
What will be the output of the program ? #include void fun(void *p); int i; int main() { void *vptr; vptr = &i; fun(vptr); return 0; } void fun(void *p) { int **q; q = (int**)&p; printf("%d\n", **q); } |
A. | Error: cannot convert from void** to int** |
B. | Garbage value |
C. | 0 |
D. | No output |
Answer» D. No output | |
177. |
The following program reports an error on compilation. #include int main() { float i=10, *j; void *k; k=&i; j=k; printf("%f\n", *j); return 0; } |
A. | 1 |
B. | |
Answer» C. | |
178. |
What will be the output of the program ? #include int main() { char str[20] = "Hello"; char *const p=str; *p='M'; printf("%s\n", str); return 0; } |
A. | Mello |
B. | Hello |
C. | HMello |
D. | MHello |
Answer» B. Hello | |
179. |
Will the following program give any warning on compilation in TurboC (under DOS)? #include int main() { int *p1, i=25; void *p2; p1=&i; p2=&i; p1=p2; p2=p1; return 0; } |
A. | Yes |
B. | No |
Answer» C. | |
180. |
Which of the statements is correct about the program? #include int main() { int i=10; int *j=&i; return 0; } |
A. | j and i are pointers to an int |
B. | i is a pointer to an int and stores address of j |
C. | j is a pointer to an int and stores address of i |
D. | j is a pointer to a pointer to an int and stores address of i |
Answer» D. j is a pointer to a pointer to an int and stores address of i | |
181. |
Which of the following statements correct about k used in the below statement?char ****k; |
A. | k is a pointer to a pointer to a pointer to a char |
B. | k is a pointer to a pointer to a pointer to a pointer to a char |
C. | k is a pointer to a char pointer |
D. | k is a pointer to a pointer to a char |
Answer» C. k is a pointer to a char pointer | |
182. |
Will the program compile? #include int main() { char str[5] = "IndiaBIX"; return 0; } |
A. | 1 |
B. | |
Answer» B. | |
183. |
In the following program add a statement in the function fun() such that address of a gets stored in j? #include int main() { int *j; void fun(int**); fun(&j); return 0; } void fun(int **k) { int a=10; /* Add a statement here */ } |
A. | **k=a; |
B. | k=&a; |
C. | *k=&a |
D. | &k=*a |
Answer» D. &k=*a | |
184. |
What will be the output of the program ? #include #include int main() { int i, n; char *x="Alice"; n = strlen(x); *x = x[n]; for(i=0; i |
A. | Alice |
B. | ecilA |
C. | Alice lice ice ce e |
D. | lice ice ce e |
Answer» E. | |
185. |
Is this a correct way for NULL pointer assignment? int i=0;char *q=(char*)i; |
A. | Yes |
B. | No |
Answer» C. | |
186. |
Are the three declarations char **apple, char *apple[], and char apple[][] same? |
A. | 1 |
B. | |
Answer» C. | |
187. |
Which of the statements is correct about the program? #include int main() { float a=3.14; char *j; j = (char*)&a; printf("%d\n", *j); return 0; } |
A. | It prints ASCII value of the binary number present in the first byte of a float variable a. |
B. | It prints character equivalent of the binary number present in the first byte of a float variable a. |
C. | It will print 3 |
D. | It will print a garbage value |
Answer» B. It prints character equivalent of the binary number present in the first byte of a float variable a. | |
188. |
Point out the error in the program #include int main() { int a[] = {10, 20, 30, 40, 50}; int j; for(j=0; j |
A. | Error: Declaration syntax |
B. | Error: Expression syntax |
C. | Error: LValue required |
D. | Error: Rvalue required |
Answer» D. Error: Rvalue required | |
189. |
What will be the output of the program ? #include int main() { char str[] = "peace"; char *s = str; printf("%s\n", s++ +3); return 0; } |
A. | peace |
B. | eace |
C. | ace |
D. | ce |
Answer» E. | |
190. |
What will be the output of the program ? #include int main() { int x=30, *y, *z; y=&x; /* Assume address of x is 500 and integer is 4 byte size */ z=y; *y++=*z++; x++; printf("x=%d, y=%d, z=%d\n", x, y, z); return 0; } |
A. | x=31, y=502, z=502 |
B. | x=31, y=500, z=500 |
C. | x=31, y=498, z=498 |
D. | x=31, y=504, z=504 |
Answer» E. | |
191. |
Which of the statements is correct about the program? #include int main() { int arr[3][3] = {1, 2, 3, 4}; printf("%d\n", *(*(*(arr)))); return 0; } |
A. | Output: Garbage value |
B. | Output: 1 |
C. | Output: 3 |
D. | Error: Invalid indirection |
Answer» E. | |
192. |
Is the NULL pointer same as an uninitialised pointer? |
A. | Yes |
B. | No |
Answer» C. | |
193. |
What will be the output of the program ? #include int main() { int i=3, *j, k; j = &i; printf("%d\n", i**j*i+*j); return 0; } |
A. | 30 |
B. | 27 |
C. | 9 |
D. | 3 |
Answer» B. 27 | |
194. |
Point out the compile time error in the program given below. #include int main() { int *x; *x=100; return 0; } |
A. | Error: invalid assignment for x |
B. | Error: suspicious pointer conversion |
C. | No error |
D. | None of above |
Answer» D. None of above | |
195. |
Which of the following statements correctly declare a function that receives a pointer to pointer to a pointer to a float and returns a pointer to a pointer to a pointer to a pointer to a float? |
A. | float **fun(float***); |
B. | float *fun(float**); |
C. | float fun(float***); |
D. | float ****fun(float***); |
Answer» E. | |
196. |
Can you combine the following two statements into one? char *p; p = (char*) malloc(100); |
A. | char p = *malloc(100); |
B. | char *p = (char) malloc(100); |
C. | char *p = (char*)malloc(100); |
D. | char *p = (char *)(malloc*)(100); |
Answer» D. char *p = (char *)(malloc*)(100); | |
197. |
Is there any difference between the following two statements? char *p=0;char *t=NULL; |
A. | Yes |
B. | No |
C. | Yes |
D. | No |
Answer» C. Yes | |
198. |
What will be the output of the program ? #include int main() { static char *s[] = {"black", "white", "pink", "violet"}; char **ptr[] = {s+3, s+2, s+1, s}, ***p; p = ptr; ++p; printf("%s", **p+1); return 0; } |
A. | ink |
B. | ack |
C. | ite |
D. | let |
Answer» B. ack | |
199. |
What would be the equivalent pointer expression for referring the array element a[i][j][k][l] |
A. | ((((a+i)+j)+k)+l) |
B. | *(*(*(*(a+i)+j)+k)+l) |
C. | (((a+i)+j)+k+l) |
D. | ((a+i)+j+k+l) |
Answer» C. (((a+i)+j)+k+l) | |
200. |
Are the expression *ptr++ and ++*ptr are same? |
A. | 1 |
B. | |
C. | 1 |
D. | |
Answer» C. 1 | |