TCS NQT Input/Output Quiz- 2

Question 1

Time: 00:00:00
The missing block of code will be?

integer array[N]
Integer i=0;
max=0;
While i<N
   [missing code]
i=i+1
End while
Print max

If array[i]>max array[i]=max End If

If array[i]>max array[i]=max End If

If array[0]>max max=array[i] End If

If array[0]>max max=array[i] End If

If array[i]<max max=array[0] End if

If array[i]<max max=array[0] End if

If array[i]>max max=array[i] End if

If array[i]>max max=array[i] End if

Question 2

Time: 00:00:00
What will be the output of the following pseudo code

function f()
Integer  x,y,z
x=3,y=4,z=4;
print((z>=y>=x)?1:0);
End function

 

6

6

Zero(0)

Zero(0)

1

1

5

5

Question 3

Time: 00:00:00
What will be the output of the following pseudo code

#include<stdio.h>
int main()

    int a,b=0;
    static int c[10] = {11,22,33,44,55,66,77,88,99,100};
    for(a=0;a<7;++a)
    {
        if((c[a]%2)==1)
        b+=c[a];
    }
    printf("%d",b);
    return 0;
}

255

255

176

176

180

180

200

200

Question 4

Time: 00:00:00
What will be the output of the following code

#include<stdio.h>
Int main()
{
Int value=0,x=0;
for(x=0;x<5;x++)
{
    value++;
    Continue;
    printf(“%d”,x);
}

Zero(0)

Zero(0)

1

1

0123

0123

Noting will get printed on the output screen

Noting will get printed on the output screen

Question 5

Time: 00:00:00
What is the output of the following code

Integer digit=0
If digit
Print 1
Else
Print digit
End if

1

1

Digit

Digit

Zero(0)

Zero(0)

Nothing will be printed

Nothing will be printed

Question 6

Time: 00:00:00
What is the output of the following pseudo code

    read integer rose = 1, lotus =2;
    rose += lotus = rose
    Print rose
    Print lotus

 

21

21

12

12

11

11

22

22

Question 7

Time: 00:00:00
Jacob wants to reuse the following loop inversely-> for (mile=0;mile<dest;mile++). Which of the options is most suited?

for(mile=dest; mile>0;mile--)

for(mile=dest; mile>0;mile--)

for(mile=dest; mile>=0;mile--)

for(mile=dest; mile>=0;mile--)

for(mile=dest-1; mile>-1;mile--)

for(mile=dest-1; mile>-1;mile--)

for(mile=dest-1; mile>0;mile--)

for(mile=dest-1; mile>0;mile--)

Question 8

Time: 00:00:00
What will be the output of the following code?

#include <iostream>
using namespace std;
int main()
{
    int skip_num;
    for(skip_num=1;skip_num<=5;skip_num++){
        if(skip_num==2|| skip_num==4){
            continue;
        }
        cout<<skip_num;
    }
    return 0;
}

1 3 4 5

1 3 4 5

1 4 5

1 4 5

2 4 5

2 4 5

1 3  5

1 3  5

Question 9

Time: 00:00:00
What is the output of the following code

#include<stdio.h>
int problem(int num);
int main()

    int solution = problem(1);
    printf("%d\n",solution);
}
int problem(int num)
{
    if(num > 5)
    exit(0);
    return(++num);
}

Zero(0)

Zero(0)

1

1

2

2

None of the mentioned

None of the mentioned

Question 10

Time: 00:00:00
What is the output of the following code

#include<iostream.h>
using namespace std;
int main () 
{
    int a=3, b=5;
    while(b--)
        a++;
    cout << a;
    return 0;
}

8

8

9

9

10

10

None of the mentioned

None of the mentioned

null
null