

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.
151. |
Bing is a web search engine owned and operated by |
A. | Microsoft |
B. | Yahoo |
C. | Alphabet Inc. |
D. | Amazon |
Answer» B. Yahoo | |
152. |
Determine the output of following C code segment:int add (int a, int b=12){return a + b;}main(){ int c;c = add (10, 20);printf("c = %d", c);} |
A. | c = 22 |
B. | c = 30 |
C. | c = 12 |
D. | c = 10 |
Answer» C. c = 12 | |
153. |
Consider the following C function in which size is the number of elements in the array E:int MyX(int *E, unsigned int size){ int Y = 0; int Z; int i, j, k; for(i = 0; i < size; i++)Y = Y + E[i]; for(i = 0; i < size; i++)for(j = i; j < size; j++){ Z = 0; for(k = i; k <= j; k++)Z = Z + E[k]; if (Z > Y)Y = Z;} return Y;}The value returned by the function MyX is the |
A. | maximum possible sum of elements in any sub-array of array E |
B. | maximum element in any sub-array of array E. |
C. | sum of the maximum elements in all possible sub-arrays of array E. |
D. | The sum of all the elements in the array E. |
Answer» B. maximum element in any sub-array of array E. | |
154. |
Consider the C struct defined below:struct data { int marks [100]; char grade; int cnumber;};struct data student;The base address of student is available in register R1. The field student. grade can be accessed efficiently using |
A. | Post-increment addressing mode, (R1) + |
B. | Pre-decrement addressing mode, - (R1) |
C. | Register direct addressing mode. R1 |
D. | Index addressing mode. X (R1). Where X is an offset represented in 2’s complement 16- bit representation. |
Answer» E. | |
155. |
Consider the following recursive function.Int function (int x, int y) { If (y <= 0) return x; return function (y, x%y); }The above recursive function computes ______. |
A. | yx |
B. | GCD of x and y |
C. | xy |
D. | LCM of x and y |
Answer» C. xy | |
156. |
An array of 2 two byte integers is stored in big endian machine in byte addresses as shown below. What will be its storage pattern in little endian machine?AddressData0 × 104780 × 103560 × 102340 × 10112 |
A. | 0 × 104 120 × 103 560 × 102 340 × 101 78 |
B. | 0 × 104 120 × 103 340 × 102 560 × 101 78 |
C. | 0 × 104 560 × 103 780 × 102 120 × 101 34 |
D. | 0 × 104 560 × 103 120 × 102 780 × 101 34 |
Answer» D. 0 × 104 560 × 103 120 × 102 780 × 101 34 | |
157. |
A language with string manipulation facilities uses the following operations.head(s) - returns the first character of the stringstail(s) - returns all but the first character of the stringsconcat (s1, s2) - concatenates string s1 with s2.The output of concat (head(s), head(tail(tail(s)))), where s is acbc is |
A. | ab |
B. | ba |
C. | ac |
D. | aa |
Answer» B. ba | |
158. |
Consider the following declaration :struct addr {char city[10];char street[30];int pin;};struct {char name[30];Int gender;struct addr locate ;} person, *kd = &person ; Then *(kd-> name +2) can be used instead of |
A. | person.name +2 |
B. | kd-> (name +2) |
C. | *((*kd).name + 2) |
D. | either (a) or (b), but not (c) |
Answer» D. either (a) or (b), but not (c) | |
159. |
If ‘a’ is declared as one-dimensional array in ‘C’ thena) *(a + i) is same as *(&a[i])b) *(a + i) is same as *a + ic) &a[i] is same as a + i - 1d) *(a + i) is same as a[i]Which of the above statements are incorrect? |
A. | (a) and (b) |
B. | (a) and (d) |
C. | (b) and (c) |
D. | (c) and (d) |
Answer» D. (c) and (d) | |
160. |
______ Programming style is a single entry single exit program construct. |
A. | High level |
B. | Exploratory |
C. | Structured |
D. | All options are wrong |
Answer» D. All options are wrong | |
161. |
_______ are words that a programming language has set aside for its own use. |
A. | Reserved Keys |
B. | Control Structures |
C. | Reserved words |
D. | Control Words |
Answer» D. Control Words | |
162. |
Let A be a square matrix of size n × n. Consider the following pseudocode. What is the expected output?C = 100;for I = 1 to n dofor j = 1 to n do { Temp = A[i] [j] + C; A[i] [j] = A[j] [i]; A[J] [I] = Temp – C; }for I = 1 to n dofor j = 1 to n dooutput (A[i] [j]); |
A. | The matrix A itself |
B. | Transpose of the matrix A |
C. | Adding 100 to the upper diagonal elements and subtracting 100 from lower diagonal elements of A |
D. | None of the above |
Answer» B. Transpose of the matrix A | |
163. |
A program P reads in 500 integers in the range [0..100] representing the scores of 500 students. It then prints the frequency of each score above 50. What would be the best way for P to store the frequencies? |
A. | An array of 50 numbers |
B. | An array of 100 numbers |
C. | An array of 500 numbers |
D. | A dynamically allocated array of 550 numbers |
Answer» B. An array of 100 numbers | |
164. |
Consider the following declaration of an array in ‘C’ language:int A[6] = {1, 2, 3, 5};Which of the following statements is true? |
A. | Both A[2] and 2[A] represent the value 2. |
B. | Both A[2] and 2[A] represent the value 3 |
C. | A[2] is the correct way to access an element of A, but 2[A] will give an error |
D. | The last two elements of the array A are 3 and 5 |
Answer» C. A[2] is the correct way to access an element of A, but 2[A] will give an error | |
165. |
For a C program accessing X[i][j][k], the following intermediate code is generated by aCompiler. Assume that the size of an integer is 32 bits and the size of a character is 8 bits.t0 = i ∗ 1024t1 = j ∗ 32t2 = k ∗ 4t3 = t1 + t0t4 = t3 + t2t5 = X[t4]Which one of the following statements about the source code for the C program is CORRECT? |
A. | X is declared as “int X[32][32][8]”. |
B. | X is declared as “int X[4][1024][32]”. |
C. | X is declared as “char X[4][32][8]”. |
D. | X is declared as “char X[32][16][2]”. |
Answer» B. X is declared as “int X[4][1024][32]”. | |
166. |
Consider the following C program:#includevoid fun1 (char *s1, char *s2) { char *tmp ; tmp = s1 ; s1 = s2 ; s2 = tmp ;}void fun2 (char **s1, char **s2) { char *tmp ; tmp = * s1 ; * s1 = * s2 ; * s2 = tmp ;}int main ( ) { char *str1 = “Hi”, *str2 = “Bye” ; fun1 (str1, str2) ; printf (“%s %s “, str1, str2) ; fun2 (&str1, &str2) ; printf (“%s %s “, str1, str2) ; return 0 ;}The output of the program above is |
A. | Hi Bye Bye Hi |
B. | Hi Bye Hi Bye |
C. | Bye Hi Hi Bye |
D. | Bye Hi Bye Hi |
Answer» B. Hi Bye Hi Bye | |
167. |
Header files often have the file extension |
A. | .H |
B. | HE |
C. | .HEA |
D. | .HEAD |
Answer» B. HE | |
168. |
Consider the following two functions.viod fun1 (int n) {if (n == 0) return;printf(“%d”, n);fun2(n – 2);printf (“%d”, n);}void fun2(int n) {if (n == 0) return;printf (“%d”, n);fun1(++n);printf(“%d”, n);}The output printed when fun1 (5) is called is |
A. | 53423122233445 |
B. | 53423120112233 |
C. | 53423122132435 |
D. | 53423120213243 |
Answer» B. 53423120112233 | |
169. |
Consider the following segment of C codeint j, n;j = 1;while (j <= n) j=j*2;The number of comparisons made in the execution of the loop for any n > 0 is |
A. | \(\left\lfloor {{{\log }_2}\,\,n} \right\rfloor \times n\) |
B. | \(n\) |
C. | \(\lfloor \log_2 n \rfloor\) |
D. | \(\lfloor \log_2 n \rfloor + 1\) |
Answer» E. | |
170. |
Consider the following C program#include main() { float sum = 0.0; j = 1.0, i = 2.0; while ( i/j > 0.001 ) { j = j + 1; sum = sum + i/j ; printf ( “%f\n”, sum ); } }How many lines of output does this program produce? |
A. | 0 – 9 lines of output |
B. | 10 – 19 lines out output |
C. | 20 – 29 lines of output |
D. | More than 29 lines of output |
Answer» B. 10 – 19 lines out output | |
171. |
Consider the following C program segment.#includeint main(){char s1[7] = "1234", *p;p = s1 + 2; *p = ‘0’;printf("%s", s1);}What will be printed by the program? |
A. | 12 |
B. | 120400 |
C. | 1204 |
D. | 1034 |
Answer» D. 1034 | |
172. |
In context of command line arguments in C programming, which of the following is true about argv? |
A. | It is an array of character pointers |
B. | It is pointer to an array of character pointers. |
C. | It is an array of characters |
D. | It is a simple integer variable |
Answer» B. It is pointer to an array of character pointers. | |
173. |
Determine the output of the following.#includeint f(int a){a>20?return(10):return(20);}int main(){int b;b=f(20);printf(“%d\n”,b);return 0;} |
A. | Error: Return statement cannot be used with conditional operators |
B. | Error: Two return statements cannot be used in any function |
C. | No error |
D. | Error: Prototype declaration |
Answer» B. Error: Two return statements cannot be used in any function | |
174. |
If n has the value 3, then the statement a[++n] = n++; |
A. | assigns 3 to a[5] |
B. | assigns 4 to a[5] |
C. | assigns 4 to a[4] |
D. | what is assigned is compiler dependent |
Answer» E. | |
175. |
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): Workstations are often used in engineering applications, especially for interactive design work.Reason (R): Work stations with graphics I / O capability have a computational power that is significantly higher than that of personal computers. |
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 | |
176. |
Match the columns.C commandsDescription1. getch();a. This command terminates the C program (main function) and returns 0.2. return 0;b. This indicates the end of the main function3. }c. This is the main function from where execution of any C program begins.4. int main(). This command waits for any character input from the keyboard. |
A. | 1 - c, 2 - d, 3 - a, 4 - b |
B. | 1 - d, 2 - b, 3 - a, 4 - c |
C. | 1 - d, 2 - a, 3 - b, 4 - c |
D. | 1 - c, 2 - b, 3 - a, 4 - d |
Answer» D. 1 - c, 2 - b, 3 - a, 4 - d | |
177. |
Match the two lists and choose the correct answer form the code given below:List IList II(a) a × b – c × d(i) 3 * x *x - 2*x + 5(b) (m + n) (a + b)(ii) a * b – c * d(c) 3x2 _+ 2x + 5(iii) (a + b * c) / (d + e)(d) \(\frac{(a+b×c)}{d+e}\)(iv)(m + n) * (a + b) |
A. | (a) – (ii), (b) – (iv), (c) – (i), (d) – (iii) |
B. | (a) – (iv), (b) – (ii), (c) – (iii), (d) – (i) |
C. | (a) – (i), (b) – (ii), (c) – (iii), (d) – (iv) |
D. | (a) – (iii), (b) – (iv), (c) – (ii), (d) – (i) |
Answer» B. (a) – (iv), (b) – (ii), (c) – (iii), (d) – (i) | |
178. |
Assertion (A): If ‘char a[10];’ is defined in one file and ‘extern char *a;’ is declared in another file then it does not work.Reason (R): The declaration ‘extern char *a;’ does not declare an array and therefore does not match the actual definition. |
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» B. Both (A) and (R) are true, but (R) is not the correct explanation of (A) | |
179. |
Consider the following C program:#include int r( ){static int num = 7;return num--;}int main ( ) {for (r( ) ;r ( ) ;r ( ) )printf(“ % d”, r( ) );return 0;}Which one of the following values will be displayed on execution of the programs? |
A. | 41 |
B. | 52 |
C. | 63 |
D. | 630 |
Answer» C. 63 | |
180. |
Consider the following C++ programint a (int m){ return ++m; }int b(int&m){ return ++m;}intc(char &m){ return ++m; }void: main () {int p = 0, q = 0, r = 0;p + = a(b(p));qt = b(a(q));r+ = a(c(r));cout<< p <<< I;}Assuming the required header files are already included, the above program |
A. | results in compilation error |
B. | print 123 |
C. | print 111 |
D. | print 322 |
Answer» B. print 123 | |
181. |
Arrange the following operators in the precedence order of highest to lowest:(a) ==(b) ++(c) %(d) &The correct order of precedence is: |
A. | (d), (b), (c), (a) |
B. | (b), (c), (a), (d) |
C. | (a), (d), (b), (c) |
D. | (c), (a), (d), (b) |
Answer» C. (a), (d), (b), (c) | |
182. |
In C++, casting operator function should satisfy, which of the following conditions?I: It must be a member of a classII: It must not specify a return typeIII: It must not have any argument |
A. | I and II only |
B. | I, II and III |
C. | I and III only |
D. | II and II only |
Answer» C. I and III only | |
183. |
Consider the following two C code segment. Y and X are one- and two-dimensional arrays of size n and n × n respectively, where 2 ≤ n ≤ 10. Assume that in both code segments, elements of y are initialized to 0 and each element X[i] [j] of array X is initialized to i + j. Further assume that when stored in main memory all elements of x are in same main memory page frame.Code segment 1: //initialize elements of y to 0 //initialize elements X[i] [j] of X to i+j for (i = 0; i < n; i++) Y[i] += X[0] [i];Code Segment 2: //initialize elements of Y to 0 //initialize elements X[i] [j] of X to i+j for (i = 0; i < n; i++) Y[i] += X[i] [0];Which of the following statements is/are correct?S1: Final contents of array Y will be same in both code segmentsS2: Elements of array X accessed inside the for loop shown in code segment 1 are contiguous in main memoryS3: Elements of array X accessed inside the for loop shown in code segment 2 are contiguous in main memory |
A. | Only S3 is correct |
B. | Only S2 is correct |
C. | Only S1 and S2 are correct |
D. | Only S1 and S3 are correct |
Answer» D. Only S1 and S3 are correct | |
184. |
Hexadecimal equivalent of binary number 10011011 is |
A. | 9B |
B. | B9 |
C. | 9C |
D. | C9 |
Answer» B. B9 | |
185. |
Consider the following C program which is supposed to compute the transpose of a given 4 × 4 matrix M. Note that, there is an X in the program which indicates some missing statements. Choose the correct option to replace X in the program.#include#define ROW 4#define COL 4int M[ROW][COL] = {{1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,16}};main(){ int i, j,t; for (i=0;i<4;++i) { X } for(i=0;i<4;++i) for(j=0;j<4;++j) printf(“%d”, M[i][j]);} |
A. | for(j=i;j<4;j++) t= M[i][j]; M[i][j]= M[j][i]; M[j][i]=t; } |
B. | for(j=0;j<4;++j){ M[i][j]=t; t= M[j][i]; M[j][i]=M[i][j]; } |
C. | for(j=i;j<4;++j){ t= M[j][i]; M[i][j]= M[j][i]; M[i][j]= t; } |
D. | for(j=i;j<4;++j){ M[i][j]=t; t= M[j][i]; M[j][i]=M[i][j]; } |
Answer» B. for(j=0;j<4;++j){ M[i][j]=t; t= M[j][i]; M[j][i]=M[i][j]; } | |
186. |
Assume A and B are non-zero positive integers. The following code segmentwhile (A ! = B ){If(A>B )A - = B; else B - = A;}cout< |
A. | Computes the LCM of two numbers Y, |
B. | Divides the larger number by the smaller number |
C. | Computes the GCD of two numbers |
D. | Finds the smaller of two numbers |
Answer» D. Finds the smaller of two numbers | |
187. |
Consider the following recursive C function that takes two argumentsunsigned int rer (unsigned int n, unsigned int r) {if (n > 0) return (n%r + rer (n/r, r));else return 0;}What is the return value of the function rer when it is called as rer (513, 2)? |
A. | 9 |
B. | 8 |
C. | 5 |
D. | 2 |
Answer» E. | |
188. |
In a compact one-dimensional array representation for lower triangular matrix (all elements above diagonal are zero) of size n × n, non zero elements of each row are stored one after another, starting from first row, the index of (i, j)th element in this new representation is |
A. | \(i + j\) |
B. | \(j+i(i-1)/2\) |
C. | \(i + j – 1\) |
D. | \(i+j(j-1)/2\) |
Answer» C. \(i + j – 1\) | |
189. |
The statement below is .....a |
A. | Declaration |
B. | Definition |
C. | Initialization |
D. | None of the above |
Answer» B. Definition | |
190. |
What is the output the program.? |
A. | Compiler error. You can not assign register value to int variable. |
B. | 80 80 |
C. | 80 0 |
D. | Compiles, but output is none. |
Answer» C. 80 0 | |
191. |
What is the output of the C Program statement.? |
A. | null |
B. | 0 |
C. | random integer number |
D. | random real number |
Answer» D. random real number | |
192. |
What is the output of the program.? |
A. | Hello Boss. |
B. | hello boss |
C. | No output |
D. | Compiler error |
Answer» E. | |
193. |
Choose a correct statement regarding automatic variables. |
A. | #include<stdio.h> |
B. | #include<stdio.h> |
C. | #include<stdio.h> |
D. | #include<stdio.h> |
Answer» E. | |
194. |
What is the difference between Declaration and Definition.? |
A. | Declaration does allocate memory for a variable. |
B. | Declaration does allocate memory for a variable. |
C. | Declaration does not allocate memory for a variable. |
D. | Declaration does not allocate memory for a variable. |
Answer» D. Declaration does not allocate memory for a variable. | |
195. |
register float a = 3.14f; |
A. | Variable a is stored in CPU registers for fast access. |
B. | Variable a is converted to int and then stored in a CPU register. |
C. | register Storage Class is ignored and treated as |
D. | You get a compiler error as you can not store non integer value in a CPU register. |
Answer» D. You get a compiler error as you can not store non integer value in a CPU register. | |
196. |
Choose a correct statement about static variable. |
A. | A static global variable can be accessed in other files. |
B. | A static global variable can be used only in a file in which it is declared. |
C. | A static global variable can not be declared without extern keyword. |
D. | Default value of a static variable is -1. |
Answer» C. A static global variable can not be declared without extern keyword. | |
197. |
Which among the following is a Global Variable.? |
A. | auto |
B. | register |
C. | static |
D. | extern |
Answer» E. | |
198. |
Which among the following is a Local Variable.? |
A. | register |
B. | auto |
C. | static |
D. | extern |
Answer» C. static | |
199. |
Find a correct statement. |
A. | Scope of auto variable = local to block or function |
B. | Scope of auto variable = global or available to all functions and blocks |
C. | Scope of auto variable = global or available to all functions and blocks |
D. | Scope of auto variable = local to block or function |
Answer» B. Scope of auto variable = global or available to all functions and blocks | |
200. |
Find a right answer. |
A. | Default value of auto variable = Garbage Value |
B. | Default value of auto variable = zero |
C. | Default value of auto variable = Garbage |
D. | Default value of auto variable = zero |
Answer» D. Default value of auto variable = zero | |