MCQOPTIONS
Saved Bookmarks
This section includes 36 Mcqs, each offering curated multiple-choice questions to sharpen your BHEL knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
What is the time complexity of the above recursive implementation of linear search? |
| A. | O(1) |
| B. | O(n) |
| C. | O(n2) |
| D. | O(n3) |
| Answer» C. O(n2) | |
| 2. |
Consider the following recursive implementation of linear search on a linked list: struct Node { int val; struct Node* next; }*head; int linear_search(struct Node *temp,int value) { if(temp == 0) return 0; if(temp->val == value) return 1; return _________; } Which of the following lines should be inserted to complete the above code? |
| A. | 1 |
| B. | 0 |
| C. | linear_search(temp, value) |
| D. | linear_search(temp->next, value) |
| Answer» E. | |
| 3. |
What will be time complexity when binary search is applied on a linked list? |
| A. | O(1) |
| B. | O(n) |
| C. | O(n2) |
| D. | O(n3) |
| Answer» C. O(n2) | |
| 4. |
Can binary search be applied on a sorted linked list in O(Logn) time? |
| A. | No |
| B. | Yes |
| Answer» B. Yes | |
| 5. |
Consider the following code snippet to search an element in a linked list: struct Node { int val; struct Node* next; }*head; int linear_search(int value) { struct Node *temp = head->next; while(temp != 0) { if(temp->val == value) return 1; _________; } return 0; } Which of the following lines should be inserted to complete the above code? |
| A. | temp = next |
| B. | temp->next = temp |
| C. | temp->next = temp |
| D. | return 0 |
| Answer» D. return 0 | |
| 6. |
Which of the following methods can be used to search an element in a linked list? |
| A. | Iterative linear search |
| B. | Iterative binary search |
| C. | Recursive binary search |
| D. | All of the mentioned |
| Answer» B. Iterative binary search | |
| 7. |
Identify the disadvantages of bit array. |
| A. | Without compression, they might become sparse |
| B. | Accessing individual bits is expensive |
| C. | Compressing bit array to byte/word array, the machine also has to support byte/word addressing |
| D. | All of the mentioned |
| Answer» E. | |
| 8. |
What will be the output of the following C code? #include <stdio.h> int main() { int x = 3, y = 2; int z = x << 1 > 5; printf("%d\n", z); } |
| A. | 1 |
| B. | 0 |
| C. | 3 |
| D. | Compile time error |
| Answer» B. 0 | |
| 9. |
What will be the output of the following C code? #include <stdio.h> int main() { int x = 3, y = 2; int z = x /= y %= 2; printf("%d\n", z); } |
| A. | 1 |
| B. | Compile time error |
| C. | Floating point exception |
| D. | Segmentation fault |
| Answer» D. Segmentation fault | |
| 10. |
What will be the output of the following C code? #include <stdio.h> int main() { int x = 1, y = 2; int z = x & y == 2; printf("%d\n", z); } |
| A. | 0 |
| B. | 1 |
| C. | Compile time error |
| D. | Undefined behaviour |
| Answer» C. Compile time error | |
| 11. |
What will be the output of the following C code? #include <stdio.h> int main() { int x = 1, y = 2; if (x && y == 1) printf("true\n"); else printf("false\n"); } |
| A. | true |
| B. | false |
| C. | compile time error |
| D. | undefined behaviour |
| Answer» C. compile time error | |
| 12. |
What will be the output of the following C code? #include <stdio.h> int main() { int x = 2, y = 2; float f = y + x /= x / y; printf("%d %f\n", x, f); return 0; } |
| A. | 2 4.000000 |
| B. | Compile time error |
| C. | 2 3.500000 |
| D. | Undefined behaviour |
| Answer» C. 2 3.500000 | |
| 13. |
What will be the output of the following C code? #include <stdio.h> int main() { int y = 2; int z = y +(y = 10); printf("%d\n", z); } |
| A. | 12 |
| B. | 20 |
| C. | 4 |
| D. | Either 12 or 20 |
| Answer» C. 4 | |
| 14. |
What will be the output of the following C code? #include <stdio.h> int main() { int x = 2, y = 0, l; int z; z = y = 1, l = x && y; printf("%d\n", l); return 0; } |
| A. | 0 |
| B. | 1 |
| C. | Undefined behaviour due to order of evaluation can be different |
| D. | Compilation error |
| Answer» C. Undefined behaviour due to order of evaluation can be different | |
| 15. |
What will be the output of the following C code? #include <stdio.h> int main() { int x = 2, y = 0; int z; z = (y++, y); printf("%d\n", z); return 0; } |
| A. | 0 |
| B. | 1 |
| C. | Undefined behaviour |
| D. | Compilation error |
| Answer» C. Undefined behaviour | |
| 16. |
What will be the output of the following C code? #include <stdio.h> int main() { int x = 2, y = 0; int z = (y++) ? 2 : y == 1 && x; printf("%d\n", z); return 0; } |
| A. | 0 |
| B. | 1 |
| C. | 2 |
| D. | Undefined behaviour |
| Answer» C. 2 | |
| 17. |
What will be the output of the following C code? #include <stdio.h> int main() { int x = 2, y = 0; int z = y && (y |= 10); printf("%d\n", z); return 0; } |
| A. | 1 |
| B. | 0 |
| C. | Undefined behaviour due to order of evaluation |
| D. | 2 |
| Answer» C. Undefined behaviour due to order of evaluation | |
| 18. |
What will be the final values of i and j in the following C code? #include <stdio.h> int x = 0; int main() { int i = (f() + g()) | g(); //bitwise or int j = g() | (f() + g()); //bitwise or } int f() { if (x == 0) return x + 1; else return x - 1; } int g() { return x++; } |
| A. | i value is 1 and j value is 1 |
| B. | i value is 0 and j value is 0 |
| C. | i value is 1 and j value is undefined |
| D. | i and j value are undefined |
| Answer» D. i and j value are undefined | |
| 19. |
What will be the final values of i and j in the following C code? #include <stdio.h> int x = 0; int main() { int i = (f() + g()) || g(); int j = g() || (f() + g()); } int f() { if (x == 0) return x + 1; else return x - 1; } int g() { return x++; } |
| A. | i value is 1 and j value is 1 |
| B. | i value is 0 and j value is 0 |
| C. | i value is 1 and j value is undefined |
| D. | i and j value are undefined |
| Answer» E. | |
| 20. |
In expression i = g() + f(), first function called depends on __________ |
| A. | Compiler |
| B. | Associativiy of () operator |
| C. | Precedence of () and + operator |
| D. | Left to write of the expression |
| Answer» B. Associativiy of () operator | |
| 21. |
What will be the output of the following C function? #include <stdio.h> void reverse(int i); int main() { reverse(1); } void reverse(int i) { if (i > 5) return ; printf("%d ", i); return reverse((i++, i)); } |
| A. | 1 2 3 4 5 |
| B. | Segmentation fault |
| C. | Compilation error |
| D. | Undefined behaviour |
| Answer» B. Segmentation fault | |
| 22. |
What will be the output of the following C function? #include <stdio.h> int main() { reverse(1); } void reverse(int i) { if (i > 5) exit(0); printf("%d\n", i); return reverse(i++); } |
| A. | 1 2 3 4 5 |
| B. | 1 2 3 4 |
| C. | Compile time error |
| D. | Stack overflow |
| Answer» E. | |
| 23. |
What will be the final value of c in the following C code snippet? (Initial values: a = 1, b = 2, c = 1) c += (-c) ? a : b; |
| A. | Syntax Error |
| B. | c = 1 |
| C. | c = 2 |
| D. | c = 3 |
| Answer» D. c = 3 | |
| 24. |
Which expression has to be present in the following? exp1 ? exp2 : exp3; |
| A. | exp1 |
| B. | exp2 |
| C. | exp3 |
| D. | All of the mentioned |
| Answer» E. | |
| 25. |
What will be the data type of the following expression? (Initial data type: a = int, var1 = double, var2 = float) expression (a < 50)? var1 : var2; |
| A. | int |
| B. | float |
| C. | double |
| D. | Cannot be determined |
| Answer» D. Cannot be determined | |
| 26. |
What will be the final values of a and c in the following C statement? (Initial values: a = 2, c = 1) c = (c) ? a = 0 : 2; |
| A. | a = 0, c = 0; |
| B. | a = 2, c = 2; |
| C. | a = 2, c = 2; |
| D. | a = 1, c = 2; |
| Answer» B. a = 2, c = 2; | |
| 27. |
What will be the output of the following C code? #include <stdio.h> void main() { int k = 8; int m = 7; k < m ? k = k + 1 : m = m + 1; printf("%d", k); } |
| A. | Compile time error |
| B. | 9 |
| C. | 8 |
| D. | Run time error |
| Answer» B. 9 | |
| 28. |
What will be the output of the following C code? #include <stdio.h> void main() { int k = 8; int m = 7; k < m ? k++ : m = k; printf("%d", k); } |
| A. | 7 |
| B. | 8 |
| C. | Compile time error |
| D. | Run time error |
| Answer» D. Run time error | |
| 29. |
What will be the output of the following C code? #include <stdio.h> void main() { 1 < 2 ? return 1 : return 2; } |
| A. | returns 1 |
| B. | returns 2 |
| C. | Varies |
| D. | Compile time error |
| Answer» E. | |
| 30. |
What will be the output of the following C code? #include <stdio.h> void main() { int k = 8; int m = 7; int z = k < m ? k = m : m++; printf("%d", z); } |
| A. | Run time error |
| B. | 7 |
| C. | 8 |
| D. | Depends on compiler |
| Answer» C. 8 | |
| 31. |
What will be the output of the following C code? #include <stdio.h> void main() { int k = 8; int m = 7; int z = k < m ? k++ : m++; printf("%d", z); } |
| A. | 7 |
| B. | 8 |
| C. | Run time error |
| D. | None of the mentioned |
| Answer» B. 8 | |
| 32. |
What will be the output of the following C code? #include <stdio.h> int main() { int y = 1, x = 0; int l = (y++, x++) ? y : x; printf("%d\n", l); } |
| A. | 1 |
| B. | 2 |
| C. | Compile time error |
| D. | Undefined behaviour |
| Answer» B. 2 | |
| 33. |
What will be the output of the following C code? #include <stdio.h> int main() { int a = 2; int b = 0; int y = (b == 0) ? a :(a > b) ? (b = 1): a; printf("%d\n", y); } |
| A. | Compile time error |
| B. | 1 |
| C. | 2 |
| D. | Undefined behaviour |
| Answer» D. Undefined behaviour | |
| 34. |
What will be the output of the following C code? #include <stdio.h> int main() { int x = 1; short int i = 2; float f = 3; if (sizeof((x == 2) ? f : i) == sizeof(float)) printf("float\n"); else if (sizeof((x == 2) ? f : i) == sizeof(short int)) printf("short int\n"); } |
| A. | float |
| B. | short int |
| C. | Undefined behaviour |
| D. | Compile time error |
| Answer» B. short int | |
| 35. |
What will be the output of the following C code? #include <stdio.h> int main() { int x = 1; int y = x == 1 ? getchar(): 2; printf("%d\n", y); } |
| A. | Compile time error |
| B. | Whatever character getchar function returns |
| C. | Ascii value of character getchar function returns |
| D. | 2 |
| Answer» D. 2 | |
| 36. |
What will be the output of the following C code? #include <stdio.h> int main() { int x = 2, y = 0; int z = (y++) ? y == 1 && x : 0; printf("%d\n", z); return 0; } |
| A. | 0 |
| B. | 1 |
| C. | Undefined behaviour |
| D. | Compile time error |
| Answer» B. 1 | |