MCQOPTIONS
Saved Bookmarks
This section includes 564 Mcqs, each offering curated multiple-choice questions to sharpen your Engineering knowledge and support exam preparation. Choose a topic below to get started.
| 151. |
A function that receives variable number of arguments should use va_arg() to extract the last argument from the variable argument list. |
| A. | True |
| B. | False |
| Answer» C. | |
| 152. |
What will be the output of the program ? #include<stdio.h> 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. | |
| 153. |
What will be the output of the program ? #include<stdio.h> 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. | |
| 154. |
What will be the output of the program? #include<stdio.h> int main() { int i=-3, j=2, k=0, m; m = ++i && ++j && ++k; printf("%d, %d, %d, %d n", i, j, k, m); return 0; } |
| A. | -2, 3, 1, 1 |
| B. | 2, 3, 1, 2 |
| C. | 1, 2, 3, 1 |
| D. | 3, 3, 1, 2 |
| Answer» B. 2, 3, 1, 2 | |
| 155. |
It is necessary that a header files should have a .h extension? |
| A. | Yes |
| B. | No |
| Answer» C. | |
| 156. |
How many bytes are occupied by near, far and huge pointers (DOS)? |
| A. | near=2 far=4 huge=4 |
| B. | near=4 far=8 huge=8 |
| C. | near=2 far=4 huge=8 |
| D. | near=4 far=4 huge=8 |
| Answer» B. near=4 far=8 huge=8 | |
| 157. |
In a function two return statements should never occur. |
| A. | Yes |
| B. | No |
| Answer» C. | |
| 158. |
Which of the statements is correct about the program? #include<stdio.h> 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. | |
| 159. |
Which of the following is the correct order of evaluation for the below expression?z = x + y * z / 4 % 2 - 1 |
| A. | * / % + - = |
| B. | = * / % + - |
| C. | / * % - + = |
| D. | * % / - + = |
| Answer» B. = * / % + - | |
| 160. |
What will be the output of the program ? #include<stdio.h> int main() { int i, a[] = {2, 4, 6, 8, 10}; change(a, 5); for(i=0; i<=4; i++) printf("%d, ", a[i]); return 0; } void change(int *b, int n) { int i; for(i=0; i<n; i++) *(b+1) = *(b+i)+5; } |
| 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 | |
| 161. |
Will the printf() statement print the same values for any values of a? #include<stdio.h> int main() { float a; scanf("%f", &a); printf("%f n", a+a+a); printf("%f n", 3*a); return 0; } |
| A. | Yes |
| B. | No |
| Answer» B. No | |
| 162. |
What will be the output of the program if the array begins 1200 in memory? #include<stdio.h> int main() { int arr[]={2, 3, 4, 1, 6}; printf("%u, %u, %u n", arr, &arr[0], &arr); return 0; } |
| A. | 1200, 1202, 1204 |
| B. | 1200, 1200, 1200 |
| C. | 1200, 1204, 1208 |
| D. | 1200, 1202, 1200 |
| Answer» C. 1200, 1204, 1208 | |
| 163. |
Which of the following is correct way to define the function fun() in the below program? #include<stdio.h> int main() { int a[3][4]; fun(a); return 0; } |
| A. | <pre><code class="cpp">void fun(int p[][4]) { } </code></pre> |
| B. | <pre><code class="cpp">void fun(int *p[4]) { } </code></pre> |
| C. | <pre><code class="cpp">void fun(int *p[][4]) { } </code></pre> |
| D. | <pre><code class="cpp">void fun(int *p[3][4]) { } </code></pre> |
| Answer» B. <pre><code class="cpp">void fun(int *p[4]) { } </code></pre> | |
| 164. |
Point out the error, if any in the program. #include<stdio.h> int main() { int a = 10, b; a >=5 ? b=100: b=200; printf("%d n", b); return 0; } |
| A. | 100 |
| B. | 200 |
| C. | Error: L value required for b |
| D. | Garbage value |
| Answer» D. Garbage value | |
| 165. |
Which of the following cannot be checked in a switch-case statement? |
| A. | Character |
| B. | Integer |
| C. | Float |
| D. | enum |
| Answer» D. enum | |
| 166. |
Which of the following statements are correct about the program? #include<stdio.h> int main() { int x = 30, y = 40; if(x == y) printf("x is equal to y n"); else if(x > y) printf("x is greater than y n"); else if(x < y) printf("x is less than y n") return 0; } |
| A. | Error: Statement missing |
| B. | Error: Expression syntax |
| C. | Error: Lvalue required |
| D. | Error: Rvalue required |
| Answer» B. Error: Expression syntax | |
| 167. |
What will be the output of the program? #include<stdio.h> int main() { int i=4, j=-1, k=0, w, x, y, z; w = i || j || k; x = i && j && k; y = i || j &&k; z = i && j || k; printf("%d, %d, %d, %d n", w, x, y, z); return 0; } |
| A. | 1, 1, 1, 1 |
| B. | 1, 1, 0, 1 |
| C. | 1, 0, 0, 1 |
| D. | 1, 0, 1, 1 |
| Answer» E. | |
| 168. |
Are the following two statement same? 1. a <= 20 ? (b = 30): (c = 30); 2. (a <=20) ? b : (c = 30); |
| A. | Yes |
| B. | No |
| Answer» C. | |
| 169. |
Macros have a local scope. |
| A. | True |
| B. | False |
| Answer» C. | |
| 170. |
Which of the following correctly shows the hierarchy of arithmetic operations in C? |
| A. | / + * - |
| B. | * - / + |
| C. | + - / * |
| D. | / * + - |
| Answer» E. | |
| 171. |
In which order do the following gets evaluated 1. Relational 2. Arithmetic 3. Logical 4. Assignment |
| A. | 2134 |
| B. | 1234 |
| C. | 4321 |
| D. | 3214 |
| Answer» B. 1234 | |
| 172. |
Associativity has no role to play unless the precedence of operator is same. |
| A. | True |
| B. | False |
| Answer» B. False | |
| 173. |
A short integer is at least 16 bits wide and a long integer is at least 32 bits wide. |
| A. | True |
| B. | False |
| Answer» B. False | |
| 174. |
If the binary eauivalent of 5.375 in normalised form is 0100 0000 1010 1100 0000 0000 0000 0000, what will be the output of the program (on intel machine)? #include<stdio.h> #include<math.h> int main() { float a=5.375; char *p; int i; p = (char*)&a; for(i=0; i<=3; i++) printf("%02x n", (unsigned char)p[i]); return 0; } |
| A. | 40 AC 00 00 |
| B. | 04 CA 00 00 |
| C. | 00 00 AC 40 |
| D. | 00 00 CA 04 |
| Answer» D. 00 00 CA 04 | |
| 175. |
A header file contains macros, structure declaration and function prototypes. |
| A. | True |
| B. | False |
| Answer» B. False | |
| 176. |
A float occupies 4 bytes. If the hexadecimal equivalent of these 4 bytes are A, B, C and D, then when this float is stored in memory in which of the following order do these bytes gets stored? |
| A. | ABCD |
| B. | DCBA |
| C. | 0xABCD |
| D. | Depends on big endian or little endian architecture |
| Answer» E. | |
| 177. |
What will be the output of the program? #include<stdio.h> int sumdig(int); int main() { int a, b; a = sumdig(123); b = sumdig(123); printf("%d, %d n", a, b); return 0; } int sumdig(int n) { int s, d; if(n!=0) { d = n%10; n = n/10; s = d+sumdig(n); } else return 0; return s; } |
| A. | 4, 4 |
| B. | 3, 3 |
| C. | 6, 6 |
| D. | 12, 12 |
| Answer» D. 12, 12 | |
| 178. |
In a macro call the control is passed to the macro. |
| A. | True |
| B. | False |
| Answer» C. | |
| 179. |
What will be the output of the program ? #include<stdio.h> int main() { char str = "IndiaBIX"; printf("%s n", str); return 0; } |
| A. | Error |
| B. | IndiaBIX |
| C. | Base address of |
| D. | <i class="C-code">str</i> |
| E. | No output |
| Answer» B. IndiaBIX | |
| 180. |
Which of the following function sets first n characters of a string to a given character? |
| A. | strinit() |
| B. | strnset() |
| C. | strset() |
| D. | strcset() |
| Answer» C. strset() | |
| 181. |
What will be the output of the program ? #include<stdio.h> int main() { char str1[] = "Hello"; char str2[10]; char *t, *s; s = str1; t = str2; while(*t=*s) *t++ = *s++; printf("%s n", str2); return 0; } |
| A. | Hello |
| B. | HelloHello |
| C. | No output |
| D. | ello |
| Answer» B. HelloHello | |
| 182. |
If the size of pointer is 4 bytes then What will be the output of the program ? #include<stdio.h> int main() { char *str[] = {"Frogs", "Do", "Not", "Die", "They", "Croak!"}; printf("%d, %d", sizeof(str), strlen(str[0])); return 0; } |
| A. | 22, 4 |
| B. | 25, 5 |
| C. | 24, 5 |
| D. | 20, 2 |
| Answer» D. 20, 2 | |
| 183. |
What will be the output of the program (myprog.c) given below if it is executed from the command line? cmd> myprog friday tuesday sunday /* myprog.c */ #include<stdio.h> int main(int argc, char *argv[]) { printf("%c", *++argv[1]); return 0; } |
| A. | r |
| B. | f |
| C. | m |
| D. | y |
| Answer» B. f | |
| 184. |
Usually recursion works slower than loops. |
| A. | Yes |
| B. | No |
| Answer» B. No | |
| 185. |
What will be the output of the program? #include<stdio.h> int main() { const int x=5; const int *ptrx; ptrx = &x; *ptrx = 10; printf("%d n", x); return 0; } |
| A. | 5 |
| B. | 10 |
| C. | Error |
| D. | Garbage value |
| Answer» D. Garbage value | |
| 186. |
Point out the error in the program (in Turbo-C). #include<stdio.h> #define MAX 128 int main() { const int max=128; char array[max]; char string[MAX]; array[0] = string[0] = 'A'; printf("%c %c n", array[0], string[0]); return 0; } |
| A. | Error: unknown max in declaration/Constant expression required |
| B. | Error: invalid array string |
| C. | None of above |
| D. | No error. It prints A A |
| Answer» B. Error: invalid array string | |
| 187. |
A function may have any number of return statements each returning different values. |
| A. | True |
| B. | False |
| Answer» B. False | |
| 188. |
Names of functions in two different files linked together must be unique |
| A. | True |
| B. | False |
| Answer» B. False | |
| 189. |
Input/output function prototypes and macros are defined in which header file? |
| A. | conio.h |
| B. | stdlib.h |
| C. | stdio.h |
| D. | dos.h |
| Answer» D. dos.h | |
| 190. |
What will be the output of the program ? #include<stdio.h> #include<string.h> int main() { char str[] = "India 0 BIX 0"; printf("%s n", str); return 0; } |
| A. | BIX |
| B. | India |
| C. | India BIX |
| D. | India 0BIX |
| Answer» C. India BIX | |
| 191. |
What will be the output of the program in Turbo C (under DOS)? #include<stdio.h> int main() { struct emp { char *n; int age; }; struct emp e1 = {"Dravid", 23}; struct emp e2 = e1; strupr(e2.n); printf("%s n", e1.n); return 0; } |
| A. | Error: Invalid structure assignment |
| B. | DRAVID |
| C. | Dravid |
| D. | No output |
| Answer» C. Dravid | |
| 192. |
Point out the error in the program? #include<stdio.h> #include<string.h> void modify(struct emp*); struct emp { char name[20]; int age; }; int main() { struct emp e = {"Sanjay", 35}; modify(&e); printf("%s %d", e.name, e.age); return 0; } void modify(struct emp *p) { p ->age=p->age+2; } |
| A. | Error: in structure |
| B. | Error: in prototype declaration unknown struct emp |
| C. | No error |
| D. | None of above |
| Answer» C. No error | |
| 193. |
The '.' operator can be used access structure elements using a structure variable. |
| A. | True |
| B. | False |
| Answer» B. False | |
| 194. |
Can we specify a variable filed width in a scanf() format string? |
| A. | Yes |
| B. | No |
| Answer» C. | |
| 195. |
In a function that receives variable number of arguments the fixed arguments passed to the function can be at the end of argument list. |
| A. | True |
| B. | False |
| Answer» C. | |
| 196. |
What is the purpose of fflush() function. |
| A. | flushes all streams and specified streams. |
| B. | flushes only specified stream. |
| C. | flushes input/output buffer. |
| D. | flushes file buffer. |
| Answer» B. flushes only specified stream. | |
| 197. |
Point out the error in the program #include<stdio.h> int main() { int i; #if A printf("Enter any number:"); scanf("%d", &i); #elif B printf("The number is odd"); return 0; } |
| A. | Error: unexpected end of file because there is no matching |
| B. | <i class="C-code">#endif</i> |
| C. | The number is odd |
| D. | Garbage values |
| E. | None of above |
| Answer» B. <i class="C-code">#endif</i> | |
| 198. |
Does there exist any way to make the command-line arguments available to other functions without passing them as arguments to the function? |
| A. | Yes |
| B. | No |
| Answer» B. No | |
| 199. |
Which of the following statements correct about the below program? #include<stdio.h> int main() { union a { int i; char ch[2]; }; union a u1 = {512}; union a u2 = {0, 2}; return 0; } 1: u2 CANNOT be initialized as shown. 2: u1 can be initialized as shown. 3: To initialize char ch[] of u2 '.' operator should be used. 4: The code causes an error 'Declaration syntax error' |
| A. | 1, 2 |
| B. | 2, 3 |
| C. | 1, 2, 3 |
| D. | 1, 3, 4 |
| Answer» D. 1, 3, 4 | |
| 200. |
Is there any difference int the following declarations? int fun(int arr[]);int fun(int arr[2]); |
| A. | Yes |
| B. | No |
| Answer» C. | |