# TCS Ninja Coding Questions with Answers | TCS Ninja Coding Questions 2020 | TCS Ninja Programming MCQ Questions

77. What is the output of this C code ?

A. I am 5

B. I am not 5

C. I am different

D. Error

E. None of these

78. Ashima wants to print a pattern which includes checking and changing a variables value iteratively She decides to use a loop/condition Which of the following options should she use such that the body of the loop/condition is executed at least once whether the variable satisfies the entering condition or not ?

A. For loop

B. While loop

C. Do-while loop

D. Switch case

E. None of these

### Answer : C. Do-while loop

79. The construct “if (condition) then A else B” is used for which of the following purposes ?

A. Decision making

B. Iteration

C. Recursion

D. Object oriented programming

### Answer : A. Decision making

80. Integer a = 40, b = 35, c = 20, d = 10
Comment about the output of the following two statements.
I . Print a*b/c-d
II . Print a*b/(c-d)

A. Differ by 80

B. Same

C. Differ by 50

D. Differ by 160

81. What is the output of the following pseudo code ?

A. 411.4

B. 411

C. 410.4

D. 410

E. None of these

82. Ravi and Rupali are asked to write a program to sum the rows of 2X2 matrices stored in the array A.
Ravi writes the following code (Code A):

`for n = 0 to 1 sumRow1[n] = A[n] + A[n]end `

Rupali writes the following code (Code B):

`sumRow1 = A + AsumRow1 = A + A`

Comment upon these codes (Assume no loop unrolling done by compiler) ?

A. Code a will execute faster than b.

B. Code b will execute faster than a.

C. Code a is logically incorrect.

D. Code b is logically incorrect

### Answer : B. Code b will execute faster than a

83. What is the output of this C code ?

A. We are equal.

B. I am greater.

C. I am lesser.

D. This code will generate an error.

### Answer : D. This code will generate an error

84. What is the difference between a function and a method ?

A . Function is the named code unlike method which is part of an object
B . Function contained in an object is called a method
C . Function cannot change variables outside its scope unlike method
D . There is no difference between the two

### Answer : A. Function is the named code unlike method which is part of an object

85. Find the output :

A . 80

B . 40

C . 32

D . 72