TCS NQT Input/Output Quiz- 3

Question 1

Time: 00:00:00

23.What will be the output of the following code below 



#include <iostream>
using namespace std;
void f(int *p,int *m){
   *m=*m+3;
   *p=*p+*m;
   return;
}
int main(){
   int i=5,j=6;
   int k=0;
   f(&i,&j);
   k=i*j;
   printf("%d",k);
   return 0;
}

138  

138  

126  

126  

135  

135  

134

134

Question 2

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

#include <iostream>
using namespace std;
int main()
{   int i,j,num=4;
   for(i=4;i>0;i--){
       for(j=num;j>1;j--){
           printf("*");
       }
       num--;
       printf("\n");
   }
   return 0;
}

****   ***     **       *

****   ***     **       *

***   **     *

***   **     *

*** ** *

*** ** *

None of the mentioned

None of the mentioned

Question 3

Time: 00:00:00


What is the output of below code?

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

324

324

245

245

128

128

None of the mentioned

None of the mentioned

Question 4

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

#include <iostream>
using namespace std;
float foo(int i);
int main()
{
   float x;
   x=foo(10);
   printf("%0.2f\t",x);
   return 0;
}
float foo(int i){
   float j=5;
   j=j/i;
   printf("%0.3f",j);
   return j;
}

0.5000.5  

0.5000.5  

0.5000.50  

0.5000.50  

0.50.5  

0.50.5  

0.500.5

0.500.5

Question 5

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

#include <iostream>
using namespace std;

int main(){
 int a=4,b=2;
 int Exp=(a+b)/b;
 int Exp2=a+b/b;
 int Exp3=a+(b/b);
 printf("%d%d%d",Exp,Exp2,Exp3);
   return 0;
}

3 3 3  

3 3 3  

3 3 5  

3 3 5  

5 5 5  

5 5 5  

3 5 5

3 5 5

Question 6

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

READ integer coins=15 split=3 rest
--coins
rest=coins%split
Write rest

1

1

0

0

3

3

2

2

Question 7

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

#include <stdio.h>
int main()
{
int i=3;
switch(i)
{
   case 0:printf("apple");
   break;
   case 1+0:printf("banana");
   break;
   case 5/2:printf("carrot");
   break;
   case 8%5:printf("dates ");
   break;
}
   return 0;
}

Apple  

Apple  

Banana  

Banana  

Carrot  

Carrot  

dates

dates

Question 8

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


Read a=5

Initialize res & res1
res=a++
res1=++a
res--
--res1
res-=res1

-3

-3

-2

-2

-1

-1

Question 9

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

#include <stdio.h>
int main()
{
int toys;
for(;;toys++)
{
printf("%d",toys);
if(toys++==4)
break;
}
}

Loops infinitely  

Loops infinitely  

024  

024  

Compilation error  

Compilation error  

01234

01234

Question 10

Time: 00:00:00
What is the output of the below code?
#include <iostream>
using namespace std;
int main()
{
  int a=0;
  if(a++){
      cout<<"YES";
  }
  else{
      cout<<"NO";
   }


    return 0;

}

YES

YES

NO

NO

Error

Error

No output

No output

null
null