# Iteration Recursion and Decision Questions for Sapient Nitro

Question 1 Time: 00:00:00
Predict the output of the questions -
```Function main() {
double d = 123.4
static float f =123.4
if (d==f)
print ”Both of them are equal”
else if( f > d )
print ”Float is greater”
else
print ”Double is greater”
}``` Float is greater

Float is greater

Double is greater

Double is greater

Code will generate error

Code will generate error

Both of them are equal

Both of them are equal

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

Start

Question 2 Time: 00:00:00
As a project, Parag wants to write a code which should increment its value until a condition is satisfied. Which type of structure should he be using? For

For

While

While

Do while

Do while

Perforate

Perforate

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

Start

Question 3 Time: 00:00:00
Predict the output of the following code

int p = 1256, q ,r, s=10;

q=p/s;

r=p-q;

print r; 126

126

1131

1131

125.6

125.6

1130.6

1130.6

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

Start

Question 4 Time: 00:00:00
```function foo() {
int a = 0;
switch(a) {
case 0 : print "2";
case 2 : print "2";
case 4 : print "2";
}``` nothing gets printed

nothing gets printed

2

2

2

2

222

222

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

Start

Question 5 Time: 00:00:00
Predict the output of the following Code
```function foo()
{
int a= 245,b=5, d;
d = a/b
switch(d)
{
case 4 :print "I behaved correctly"
break
case 49:print "I behaved with accuracy"
break
default:print "Not Sure"
}
}``` I behaved correctly

I behaved correctly

I behaved with accuracy

I behaved with accuracy

Not Sure

Not Sure

Error

Error

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

Start

Question 6 Time: 00:00:00
Which of the following is used to iteratively do the same thing again and again with auto feeding values? For Loop

For Loop

do while

do while

if

if

Recursion

Recursion

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

Start

Question 7 Time: 00:00:00
```Integer a = 20, b =10, c = 20, d =10
Print a*b/c-d
Print a*b/(c-d)
Will the output be same for the two ?``` The output will have a difference of 20

The output will have a difference of 20

Will be same

Will be same

Cant be said depends on compiler

Cant be said depends on compiler

differ by 100

differ by 100

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

Start

Question 8 Time: 00:00:00
Predict the output of the following -
```#include <stdio.h>

int fun(int n)
{
if (n == 4)
return n;
else return 2*fun(n+1);
}

int main()
{
printf("%d ", fun(2));
return 0;
}``` 2

2

8

8

16

16

32

32

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

Start

Question 9 Time: 00:00:00
```What will be the output of following program ?
#include<stdio.h>
int main( )
{
int a=300,b,c;
if(a>=400)
b=300;
c=200;
printf("%d,%d\n",b,c);
return 0;
}``` Garbage value, Garbage Value

Garbage value, Garbage Value

300,200

300,200

200,300

200,300

300, Garbage, 200

300, Garbage, 200

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

Start

Question 10 Time: 00:00:00
What will be the output of code?
```#include<stdio.h>
int main( )
{
int x=3,y,z;
y=x=10;
z=x<10;
printf("\nx = %d y = %d z = %d", x,y,z);
return 0;
}``` 10,10,10

10,10,10

10,10,0

10,10,0

0,0,0

0,0,0

0,10,10

0,10,10

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