TCS NQT Input/Output Quiz- 6

Question 1

Time: 00:00:00
What will be the output of the following code below
Integer n
String s;
Set s=”readwrite”;
n=stringofLength(s);
print(n^1)

1

1

Error

Error

9

9

8

8

Question 2

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

Integer x1=1,x2=3,x3=2,x4=5
What is the output of the following two statements
Print x1*x2 + x3/x4
Print x3/x4 + x1*x2

Differ by 1

Differ by 1

Differ due to left to right precedence

Differ due to left to right precedence

Same

Same

differ by 2

differ by 2

Question 3

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

#include<iostream>
using namespace std;
int main()
{
int num=100;
printf("%d\t",--num);
printf("%d\t",num);
printf("%d\t",++num);
return 0;
}

99 100 101

99 100 101

99 100 100

99 100 100

99 99 100

99 99 100

100 100 101

100 100 101

Question 4

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

INTEGER p=50 q=100
q=(p+q)-(p=q)
Print q
Print p

150 50  

150 50  

50 200  

50 200  

50 100  

50 100  

100 50

100 50

Question 5

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

#include<iostream>
using namespace std;
int main()
{
int k=0;
while(+(+k--)!=0)
k=k+1;
printf("%d",k);
return 0;
}

1

1

-1

-1

11

11

10

10

Question 6

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

What is the output of the following code?
#include
using namespace std;
int main()
{
int a=0,b=5,c=3,sum;
sum = a++|| b++ || c++;
printf("%d %d %d %d",sum,a,b,c);
return 0;
}

9 1 5 3

9 1 5 3

1 1 6 3

1 1 6 3

8 0 5 3

8 0 5 3

1 1 6 4

1 1 6 4

Question 7

Time: 00:00:00

What will be the output of the following code below 



#include <iostream>
using namespace std;
int main()
{
    int n[3],a,num=1122;
    int i=0;
    while(i<3){
        n[i]=num/10;
        num=num%10;
        i++;
    }
    printf("%d",n[0]);
   return 0;
}

112

112

111

111

110

110

122

122

Question 8

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

#include<iostream>
using namespace std;
int fun(int x,int y){
if(x<y)
return(x,y)
else if(y!=0)
return (x+fun(x,y-1));
else
return 0;
}
int main()
{
int a=10,b=6;
int res=fun(a,b);
cout<<res;
return 0;
}

10

10

30

30

50

50

60

60

Question 9

Time: 00:00:00
What will be the output of the following code below
#include<iostream>
using namespace std;
int main()
{
for(int i=0;1;i++){
printf("In for loop %d time(s)",i+1);
break;
}
return 0;
}

In for loop 1 time(s)

In for loop 1 time(s)

In for loop 0 time(s)

In for loop 0 time(s)

In for loop -1 time(s)

In for loop -1 time(s)

In for loop 2 time(s)

In for loop 2 time(s)

Question 10

Time: 00:00:00
What is the output of below code?

#include<iostream>
using namespace std;
int main()
{
int i=8;
printf("%d%d",i>>1,i<<2);
return 0;
}

324

324

432

432

821

821

None of the mentioned

None of the mentioned

null
null