TCS NQT Recursion and Iteration Quiz- 1

Question 1

Time: 00:00:00
Recursion is similar to which of the following?

Switch Case

Switch Case

Loop

Loop

If-else

If-else

None

None

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 2

Time: 00:00:00

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 atleast once whether the variable satisfies the entering condition or not?

For loop

For loop

While Loop

While Loop

Do while loop

Do while loop

switch case

switch case

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 3

Time: 00:00:00
The construct

 “if (condition) 
         then A
   else
         then B”


is for which of the following purposes?

Decision Making

Decision Making

Iteration

Iteration

Recursion

Recursion

Object Oriented Programming

Object Oriented Programming

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 4

Time: 00:00:00
Integer a =40, b =35, c=20, d =10
Comment about the output of the following two statements •

Print a*b/c-d
Print a*b/(c-d)


Comment about the output of the following two statements

Differ by 80

Differ by 80

same

same

Differ by 50

Differ by 50

Differ by 160

Differ by 160

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 5

Time: 00:00:00
What is the output of this C code?
#include <stdio.h> 
int main(){
printf(“Hello World! %d\n”, x);
return 0;
}

Hello World! x;

Hello World! x;

Hello World! followed by a junk value

Hello World! followed by a junk value

Compile time error

Compile time error

Hello World!

Hello World!

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 6

Time: 00:00:00
What is the output of the following pseudo code?
int a =456,b,c,d=10;
b=a/d;
c=a-b;
print c;

411.4

411.4

411

411

410

410

410.4

410.4

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 7

Time: 00:00:00
How many times the below loop will be executed?
#include<stdio.h>
int main()
{
     int x, y;
    for(x=5;x>=1;x--)
    {
        for(y=1;y<=x;y++)
             printf("%d\n",y);
     }
return 0;
}

15

15

11

11

10

10

12

12

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 8

Time: 00:00:00
What will be the output of the following code:
int main()
{
int a=5,b=7;
switch(a)
{
case 5 :printf("I am 5");
break
case 7: printf("I am not 5");
break;
default:printf("I am different");
}
return 0;
}

i am 5

i am 5

i am not 5

i am not 5

I am different

I am different

Error

Error

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 9

Time: 00:00:00
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][1] + A[n][2]
end
Rupali writes the following code (Code B):
sumRow1[0] = A[0][1] + A[0][2]
sumRow1[1] = A[1][1] + A[1][2]

Code A will execute faster than Code B

Code A will execute faster than Code B

Code B will execute faster than Code A

Code B will execute faster than Code A

Code A is logically incorrect.

Code A is logically incorrect.

Code B is logically incorrect.

Code B is logically incorrect.

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 10

Time: 00:00:00
What will be the output of this code snippet ?
#include <stdio.h>
int main ()
{
int i = 0.7;
static float m = 0.7;
if (m == i)
printf ("We are equal");
else if (m > i)
printf ("I am greater");
else
printf ("I am lesser");
return 0;
}</pre

 

We are equal

We are equal

I am greater

I am greater

I am lesser

I am lesser

This code will generate an error

This code will generate an error

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

["0","40","60","80","100"]
["Need more practice!","Keep trying!","Not bad!","Good work!","Perfect!"]

Buy TCS NQT Paid Materials

Paid Materials TCS NQT

Join TCS NQT Online Classes

Personalized Analytics only Availble for Logged in users

Analytics below shows your performance in various Mocks on PrepInsta

Your average Analytics for this Quiz

Rank

-

Percentile

0%

Completed

0/0

Accuracy

0%

Comments