

MCQOPTIONS
Saved Bookmarks
This section includes 565 Mcqs, each offering curated multiple-choice questions to sharpen your Technical Programming knowledge and support exam preparation. Choose a topic below to get started.
51. |
Consider the following program of ‘C’main ( ){static int a [ ] = { 1, 2, 3, 4, 5, 6, 7, 8 } ;int i;for(i = 2; I < 6; ++i)a [a [i] ] = a [i];for (I = 0; I < 8 ; ++i)printf (“%d”, a[i]);}The output of the program is : |
A. | 1 2 3 4 5 6 7 8 |
B. | 1 2 3 3 5 5 7 8 |
C. | 1 2 2 3 3 4 4 8 |
D. | None of the above |
Answer» C. 1 2 2 3 3 4 4 8 | |
52. |
Match the following:(P)static char var;(i)A sequence of memory locations to store addresses(Q)m = malloc(10); m = NULL;(ii)A variable located in the data section of memory(R)char *ptr[10];(iii)Request to allocate a CPU register to store data(S)register int var1;(iv)A lost memory which cannot be freed |
A. | P → (ii), Q → (iv), R→ (i), S → (iii) |
B. | P → (ii), Q → (i), R → (iv), S → (iii) |
C. | P → (ii), Q → (iv), R → (iii), S → (i) |
D. | P → (iii), Q → (iv), R → (i), S → (ii) |
Answer» B. P → (ii), Q → (i), R → (iv), S → (iii) | |
53. |
Consider the C function given below.int f(int j){ static int i = 50; int k; if (i == j) { printf(“something”); k = f(i); return 0; } else return 0;}Which one of the following is TRUE? |
A. | The function returns 0 for all values of j. |
B. | The function prints the string something for all values of j. |
C. | The function returns 0 when j = 50. |
D. | The function will exhaust the runtime stack or run into an infinite loop when j = 50. |
Answer» E. | |
54. |
In the context of Visual basic, multiple controls of the same type can be grouped into an array, in the same manner as a collection of data items. Such a grouping is known as : |
A. | Primary array |
B. | An integer array |
C. | Secondary array |
D. | Control array |
Answer» E. | |
55. |
Consider the following C functionvoid swap ( int x, int y ){int tmp;tmp = x;x= y;y = tmp;}In order to exchange the values of two variables a and b: |
A. | Call swap (a, b) |
B. | Call swap (&a, &b) |
C. | swap(a, b) cannot be used as it does not return any value |
D. | swap(a, b) cannot be used as the parameters passed by value |
Answer» E. | |
56. |
Each string literal is automatically added with a ______ terminating character. |
A. | '11' |
B. | '#' |
C. | '/0' |
D. | '#0' |
Answer» D. '#0' | |
57. |
Consider the following C code segment:#includemain(){int i, j, x;scanf(“%d”, &x);i = 1; j = 1;while(i < 10) {j = j * i;i = i + 1;if(i = = x)break;}}For the program fragment above, which of the following statements about the variable i and j must be true after execution of this program? [(! (exclamation) sign denotes factorial in the answer] |
A. | (j = (x – 1)!) ∧ (i ≥ x) |
B. | (j = 9!) ∧ (i = 10) |
C. | (j = 9!) ∧ (i = 10)) ∨ ((j = (x – 1)!) ∧ (i = x)) |
D. | ((j = 9!) ∧ (i ≥ 10)) ∨ ((j = (x – 1)! ∧ (i = x)) |
Answer» E. | |
58. |
Consider the following statements :Pointers in C-programming are useful to1. Handle the data tables efficiently2. Reduce the length of a program3. Reduce the complexity of a programWhich of the above statements are correct? |
A. | 1 and 2 only |
B. | 1, 2 and 3 |
C. | 2 and 3 only |
D. | 1 and 3 only |
Answer» C. 2 and 3 only | |
59. |
Match the two lists and choose the correct answer from the code given below:List IList II(a) x ! = y(i) x is less than y(b) x < y(ii) x is greater than y(c) x > y(iii) x is less than or equal to y(d) x ≤ y(iv) x is not equal to y |
A. | (a) – (iv), (b) – (i), (c) – (ii), (d) – (iii) |
B. | (a) – (iii), (b) – (iv), (c) – (ii), (d) – (i) |
C. | (a) – (i), (b) – (ii), (c) – (iii), (d) – (iv) |
D. | (a) – (iii), (b) – (ii), (c) – (iv), (d) – (i) |
Answer» B. (a) – (iii), (b) – (iv), (c) – (ii), (d) – (i) | |
60. |
Consider the following expression in ‘C’8 + 9/3 * 3 – 4 + 9%6 ;which evaluates to: |
A. | 10 |
B. | 8 |
C. | 14 |
D. | 16 |
Answer» E. | |
61. |
Assertion (A): In ‘C’, bit fields cannot be used in a union.Reason (R): If one element of union is initialized then it also initializes other elements of the union. |
A. | Both (A) and (R) are true and (R) is the correct explanation of (A). |
B. | Both (A) and (R) are true, but (R) is not the correct explanation of (A). |
C. | (A) is true, but (R) is false. |
D. | (A) is false, but (R) is true. |
Answer» E. | |
62. |
How long does the loop for(x=0; x=3; x++){} run in C-programming? |
A. | Three times |
B. | Four times |
C. | Forever |
D. | Never |
Answer» D. Never | |
63. |
Match the following list:List – I(Storage class)List – II(Storage, initial – value, scope)(a) auto(i) register, garbage, local(b) register(ii) memory, zero, global(c) static(iii) memory, garbage, local(d) extern(iv) memory, zero, local |
A. | (a) – (iv), (b) – (ii), (c) – (iii), (d) – (i) |
B. | (a) – (i), (b) – (iv), (c) – (ii), (d) – (iii) |
C. | (a) – (ii), (b) – (iii), (c) – (i), (d) – (iv) |
D. | (a) – (iii), (b) – (i), (c) – (iv), (d) – (ii) |
Answer» E. | |
64. |
Consider the following C function#includeint main(){char c[] = "ICRBCSIT17";char *p = c;printf("%s",c + 2[p] - 6[p] - 1);return 0;}The output of the program is |
A. | SI |
B. | IT |
C. | T1 |
D. | 17 |
Answer» E. | |
65. |
A doubly linked list is declared as struct Node{ int Value; struct Note*fwd; struct Node * Bwd;}Where Fwd and Bwd represent forward and backward link to the adjacent elements of the list. Which of the following segments of code deletes the node pointed to by X from the doubly liked list, if it is assumed that X points to neither the first nor the last node of the list? |
A. | x → Bwd → Fwd = X → Fwd → Bwd = X → Bwd; |
B. | X → Bwd.Fwd = x → Fwd;X.Fwd → Bwd = X → Bwd; |
C. | X.Bwd → Fwd = Bwd;X → Fwd.Bwd = X.Bwd; |
D. | X → Bwd → Fwd = X → Bwd;X → Fwd → Bwd = X → Fwd; |
Answer» B. X → Bwd.Fwd = x → Fwd;X.Fwd → Bwd = X → Bwd; | |
66. |
Consider the following pseudo code, where x and y are positive integers.begin q : = 0 r : = x while r ≥ y do begin r : = r – y q : = q + 1 endendThe post condition that needs to be satisfied after the program terminates is |
A. | {r = qx + y ∧ r < y} |
B. | {x = qy + r ∧ r < y} |
C. | {y = qx + r ∧ 0 < r < y} |
D. | {q + 1 < r – y ∧ y > 0} |
Answer» C. {y = qx + r ∧ 0 < r < y} | |
67. |
If, A = 60 and B = 3, then using C-programming A B results in |
A. | 11100000 |
B. | 00000111 |
C. | 00111111 |
D. | 01111000 |
Answer» C. 00111111 | |
68. |
Find the invalid FOR loop structure |
A. | FOR I = 1 to N DO |
B. | FOR J = 1 TO 10 DO |
C. | FOR K = 1 TO (2*N) DO |
D. | All of these |
Answer» E. | |
69. |
Expression C = i++ causes |
A. | value of i to be assigned to C, and then I to be incremented by 1 |
B. | I to be incremented by 1, and then value of i to be assigned to C |
C. | value of i to be assigned to C |
D. | i to be incremented by 1 |
Answer» B. I to be incremented by 1, and then value of i to be assigned to C | |
70. |
In context of C++, consider following loop-statement:while (5) {cout <<"Hello";}Hello will be displayed __________ time(s) by the above loop. |
A. | Only one |
B. | Five |
C. | Zero |
D. | Infinite |
Answer» E. | |
71. |
Consider the following function written in the C programming language.void foo(char *a){if (*a && *a != ‘ ‘){foo(a+1);putchar(*a);}}The output of the above function on input “ABCD EFGH” is |
A. | ABCD EFGH |
B. | ABCD |
C. | HGFE DCBA |
D. | DCBA |
Answer» E. | |
72. |
Consider a 2-dimensional array x with 10 rows and 4 columns, with each element storing a value equivalent to the product of row number and column number. The array is stored in row-major format. If the first element x[0][0] occupies the memory location with address 1000 and each element occupies only one memory location, which all locations (in decimal) will be holding a value of 10? |
A. | 1018, 1019 |
B. | 1022, 1041 |
C. | 1017, 1036 |
D. | 1000, 1399 |
Answer» D. 1000, 1399 | |
73. |
In VB, to change the size of a dynamic array,___ is used at the point in the code where you want it to change |
A. | Dim |
B. | Redim |
C. | Chdim |
D. | Bydim |
Answer» C. Chdim | |
74. |
In high-level programming language Pascal, each program statement ends with the |
A. | comma |
B. | semicolon |
C. | double quotation marks |
D. | single quotation marks |
Answer» C. double quotation marks | |
75. |
Consider the following declaration,int a, *b = &a, **c = &b;the following program fragmenta = 4;**c = 5; |
A. | does not change the value of a |
B. | assigns address of c to a |
C. | assigns the value of b to a |
D. | assigns 5 to a |
Answer» E. | |
76. |
In context of C++, consider the following statements:I: Static member function of a class can access only static data members of the class.II: A static data member of class is shared by all the objects of the class.The true statement(s) is / are: |
A. | Only I |
B. | Only II |
C. | Both I and II |
D. | Neither I Nor II |
Answer» C. Both I and II | |
77. |
An array name is a |
A. | Subscript |
B. | Formal parameter |
C. | Memory address |
D. | Prototype |
Answer» D. Prototype | |
78. |
Determine the output of the given program.main(){int i = 8;while (i = 8){printf ("Getting out");i++;}} |
A. | Getting out is printed infinite times |
B. | Nothing is printed |
C. | Getting out is printed once |
D. | Getting out is printed 7 times |
Answer» B. Nothing is printed | |
79. |
In C programming pointer arithmetic cannot be performed on which of the following? |
A. | Dangling pointer |
B. | Void pointer |
C. | Uninitialized pointer |
D. | Integer pointer |
Answer» C. Uninitialized pointer | |
80. |
In C++, which of the following statements correctly returns the memory from the dynamic array pointer pp to the free store? |
A. | delete pp [ ]; |
B. | delete *pp; |
C. | delete [ ]pp ; |
D. | delete pp; |
Answer» D. delete pp; | |
81. |
Consider the following code segment in C++. How many times the for loop will be repeated?int main(){ Int f=1; for(;f;) cout<<”f=”<<<”\n”;< p>return 0;} |
A. | 10 times |
B. | Not even once |
C. | Repeated forever |
D. | Only once |
Answer» D. Only once | |
82. |
Consider the following C program segment.while (first <= last){if (array [middle] < search)first = middle + 1;else if (array [middle] == search)found = True;else last = middle - 1;middle = (first + last) / 2;}if (first < last) not Present = True;The cyclomatic complexity of the program segment is __________. |
A. | 3 |
B. | 4 |
C. | 5 |
D. | 6 |
Answer» D. 6 | |
83. |
Given below are some applications. Choosing from the options, pick the one that allocates a suitable data structure for implementing these applications:1. Representation of a sparse matrix2. Fast access to any item from a set of data3. Convert infix expressions to postfix expression4. Storing the terms of a long polynomial with arbitrary number of terms |
A. | Linked list, array listed list and stack |
B. | Stack, array and stack listed list |
C. | Array array, tree and stack |
D. | Linked list, array and stack listed list |
Answer» B. Stack, array and stack listed list | |
84. |
In C, when an array is passed as an argument to a function, which of the following gets passed? |
A. | Base Address of the array |
B. | Values of the elements is the array |
C. | address of the last element of the array |
D. | A duplicate of the array |
Answer» B. Values of the elements is the array | |
85. |
Consider the following code segmentvoid foo(int x, int y){x+ = y;y+ = x;}main (){int x = 5.5;foo(x, x);}What is the final value of x in both call by value and call by reference, respectively? |
A. | 5 and 16 |
B. | 5 and 12 |
C. | 5 and 20 |
D. | 12 and 20 |
Answer» D. 12 and 20 | |
86. |
A 2-D array A[4....7, -1....3] requires 2 bytes of storage space for each element. If the array is stored in row-major from having base address 100, then the address of A[6, 2] will be _____ |
A. | 150 |
B. | 200 |
C. | 112 |
D. | 116 |
Answer» E. | |
87. |
Consider the following pseudo-code fragment, where a and b are integer variables that havebeen initialized:/* Pre-conditions : (a > 1 ∧ a < b) *//* Assume that overflow never occurs */int x = 0; int p = 1;while (p < b) {p = p * a;x = x + 1;}When the while loop terminates, what will be the value of x in terms of a and b ? |
A. | ab |
B. | ba |
C. | \(\left[ {\log _a^b/*} \right]\left[ \; \right]means\;floor*/\) |
D. | \(\left[ {\log _a^b/*} \right]\left[ \; \right]means\;ceil*/\) |
Answer» E. | |
88. |
Direction: Given question consists of two statements, one labeled as the 'Assertion (A)' and the other as 'Reason (R)'. You are to examine these two statements carefully and select the answers to these items using the codes given below.Assertion (A): Most high-level programming languages include a notion of 'type' for expression.Reason (R): Type provides implicit context for many operations and it limits the set of operations that may be performed in a semantically valid program. |
A. | Both A and R are individually true and R is the correct explanation of A |
B. | Both A and R are individually true but R is NOT the correct explanation of A |
C. | A is true but R is false |
D. | A is false but R is true |
Answer» B. Both A and R are individually true but R is NOT the correct explanation of A | |
89. |
________ is a structured high level language |
A. | C |
B. | fortran |
C. | Window |
D. | JAVA |
Answer» B. fortran | |
90. |
Consider the following definition of array in C:int a [ ] [2] [3]= { { {1, 2, 3}, {4, 5, 6} }, { {10, 20, 30}, {40, 50, 60} }, { {100, 200, 300}, {400, 500, 600} }};Which of the following expressions would give value 1 for the array defined above?(a) a[0] [0] [0](b) * * * a(c) * * * a[0](d) * * a[0] [0]The correct answer is : |
A. | (a) and (c) |
B. | (a) and (d) |
C. | (a) and (b) |
D. | (c) and (d) |
Answer» D. (c) and (d) | |
91. |
_______ is an entry controlled loop. |
A. | If - then |
B. | Do while |
C. | Case |
D. | For |
Answer» E. | |
92. |
Consider the method mcq():int mcq(boolean a, boolean b, boolean c, boolean d){int ans=1;if (a) {ans = 2;}else if (b) {ans = 3;}else if (c) {if (d) {ans=4;}}return ans ;}IfM1 = Number of tests to exhaustively test mcq ();M2 = Minimum number of tests to achieve full statement coverage for mcq (); andM3 = Minimum number of tests to achieve full branch coverage for mcq ( ); then (M1, M2, M3) = ______. |
A. | (16, 3, 5) |
B. | (8,5, 3) |
C. | (8, 3, 5) |
D. | (16, 4, 4) |
Answer» B. (8,5, 3) | |
93. |
How many lines of output does the following C code produce?#include float i = 2.0;float j = 1.0;float sum = 0.0;main(){while (i / j > 0.001){j += j;sum = sum + (i / j);printf(“%f\n”, sum);}} |
A. | 8 |
B. | 9 |
C. | 10 |
D. | 11 |
Answer» B. 9 | |
94. |
Any online ‘demo’ is _______.A. An interactive presentationB. A non-interactive presentationC. Not a sequential presentationD. An active user interface |
A. | A |
B. | B |
C. | C |
D. | D |
Answer» C. C | |
95. |
Consider the functionint func(int num) {int count = 0;while(num) {count++;num >>= 1;}return(count) ;}For func(435) the value returned is |
A. | 9 |
B. | 8 |
C. | 0 |
D. | 10 |
Answer» B. 8 | |
96. |
Consider the following ANSI C program:#include #include struct Node{int value;struct Node ⋆next;};int main(){struct Node ⋆boxE, ⋆head, ⋆boxN; int index = 0;boxE = head = (struct Node ⋆) malloc (sizeof(struct Node));head -> value = index;for (index = 1; index <=3; index++){boxN = (struct Node ⋆) malloc(sizeof(struct Node));boxE -> next = boxN;boxN -> value = index;boxE = boxN; }for (index = 0; index <= 3; index++) {printf("value at index %d is %d\m", index, head -> value);head = head -> next;printf("value at index %d is %d\n", index + 1, head -> value);}}Which one of the statement below is correct about the program ? |
A. | It has a missing return which will be reported as an error by the compiler. |
B. | It dereferences an uninitialized pointer that may result in a run-time error. |
C. | Upon execution, the program goes into an infinite loop. |
D. | Upon execution, the program creates a linked-list of five nodes. |
Answer» C. Upon execution, the program goes into an infinite loop. | |
97. |
Consider the C functions foo and bar given below:Int foo (int val) {int x = 0;while (val > 0)x = x + foo (val --);}return val;}int bar (int val) {int x = 0;while (val > 0) {x = x + bar (val – 1);}return val;}Invocations of foo (3) and bar (3) will result in: |
A. | Return of 6 and 6 respectively. |
B. | Infinite loop and abnormal termination respectively. |
C. | Abnormal termination and infinite loop respectively. |
D. | Both terminating abnormally. |
Answer» D. Both terminating abnormally. | |
98. |
Considering the size of char (character) variables as one byte, what will be the size of the array declared below?char array[ ] = “programming language”; |
A. | 11 Bytes |
B. | 8 Bytes |
C. | 20 Bytes |
D. | 21 Bytes |
Answer» E. | |
99. |
An algorithm performs (log N)½ find operations, N inserts operations, (log N)½ delete operations, and (log N)½ decrease - key operations on a set of data items with keys drawn from a linearly ordered set. For a delete operation, a pointer is provided to the record that must be deleted. For the decrease - key operation, a pointer is provided to the record that has its key decreased. Which one of the following data structures is the most suited for the algorithm to use, if the goal is to achieve the best total asymptotic complexity considering all the operations? |
A. | Unsorted array |
B. | Min-heap |
C. | Sorted array |
D. | Sorted doubly linked list |
Answer» B. Min-heap | |
100. |
An array A consists of n integers in locations A[0], A[1]…. A[n-1]. It is required to shift the elements of the array cyclically to the left by k places, where 1 < = k < = (n-1). An incomplete algorithm for doing this in linear time, without using another array is given below Complete the algorithm by filling in the blanks. Assume alt the variables are suitably declared.min = n; i = 0;while (____________){ temp = A[i] ; j = i; while(______________){A[j] = ________;j = (j + k)mod n;If(j < k)mod n; min = j;}A[(n + i – k)mod n] = _______;i = ________;} |
A. | i>min; j! = (n+i)mod n; A[j+k]; temp; i+1; |
B. | i< b> |
C. | i>min; j! = (n+i+k)mod n; A[j+k]; temp; i+1; |
D. | i< b> |
Answer» E. | |