Zoho Complex and Nested Loops Quiz 1

Question 1

Time: 00:00:00
/program to count number of increment
//operations in FIRST and SECOND
#include<iostream>

using namespace std;

int main()
{
int c1 = 0, c2 = 0;

/* FIRST */
for(int i=0;i<10;i++,c1++)
for(int j=0;j<100;j++, c1++);
//do something


/* SECOND */
for(int i=0; i<100; i++, c2++)
for(int j=0; j<10; j++, c2++);
//do something

cout << " Count in FIRST = " <<c1 << endl;
cout << " Count in SECOND = " <<c2 << endl;

getchar();
return 0;
}

Count in FIRST = 1010 Count in SECOND = 1100

Count in FIRST = 1010 Count in SECOND = 1100

Count in FIRST = 101 Count in SECOND = 110

Count in FIRST = 101 Count in SECOND = 110

Count in FIRST = 10 Count in SECOND = 1000

Count in FIRST = 10 Count in SECOND = 1000

None of the above

None of the above

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

Please login to submit your explanation

Start

Question 2

Time: 00:00:00
//program to count the number of comparison
//operations executed by FIRST and SECOND */
#include<iostream>

using namespace std;

int main()
{
int c1 = 0, c2 = 0;

/* FIRST */
for(int i=0; ++c1&&i<10; i++)
for(int j=0; ++c1&&j<100;j++);
//do something

/* SECOND */
for(int i=0; ++c2&&i<100; i++)
for(int j=0; ++c2&&j<10; j++);
//do something

cout << " Count fot FIRST " <<c1 << endl;
cout << " Count fot SECOND " <<c2 << endl;
getchar();
return 0;
}

Count for FIRST 1021 Count for SECOND 1201

Count for FIRST 1021 Count for SECOND 1201

Count for FIRST 102 Count for SECOND 1201

Count for FIRST 102 Count for SECOND 1201

Cant say

Cant say

None of these

None of these

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

Please login to submit your explanation

Start

Question 3

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

i=0;for i=0:2
i=1; end

Output is suppressed

Output is suppressed

Output shows 1 3 times

Output shows 1 3 times

Output shows 1 2 times

Output shows 1 2 times

Error

Error

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

Please login to submit your explanation

Start

Question 4

Time: 00:00:00
What is the final value of j from the following code?

for j=(0:3)
j=j+1;
end

Syntactical error

Syntactical error

Declarationn error

Declarationn error

3

3

4

4

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

Please login to submit your explanation

Start

Question 5

Time: 00:00:00
In nested loops, the break statement, if present within a nested if the structure, will exit the _______

Ongoing if structure

Ongoing if structure

Entire loop

Entire loop

Ongoing loop

Ongoing loop

Entire if structure

Entire if structure

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

Please login to submit your explanation

Start

Question 6

Time: 00:00:00
#include <stdio.h>
int main()
{
int i;
if (printf("0"))
i = 3;
else
i = 5;
printf("%d", i);
return 0;
}
Run on IDE
Predict the output of above program?

3

3

6

6

03

03

08

08

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

Please login to submit your explanation

Start

Question 7

Time: 00:00:00
#include <stdio.h>
int i;
int main()
{
if (i);
else
printf("Ëlse");
return 0;
}
Run on IDE
What is correct about the above program?

else block is executed

else block is executed

if block is executed

if block is executed

cant say

cant say

none of these

none of these

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

Please login to submit your explanation

Start

Question 8

Time: 00:00:00
Output?
#include <stdio.h>
int main()
{
int c = 5, no = 10;
do {
no /= c;
} while(c--);

printf ("%dn", no);
return 0;
}

1

1

Runtime error

Runtime error

Compile error

Compile 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
# include <stdio.h>
int main()
{
int i = 0;
for (i=0; i<20; i++)
{
switch(i)
{
case 0:
i += 5;
case 1:
i += 2;
case 5:
i += 5;
default:
i += 4;
break;
}
printf("%d ", i);
}
return 0;
}

16 21

16 21

7 12 17 22

7 12 17 22

5 10 15 20

5 10 15 20

None of these

None of these

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

Please login to submit your explanation

Start

Question 10

Time: 00:00:00
Predict the output of the below program:

#include <stdio.h>
#define EVEN 0
#define ODD 1
int main()
{
int i = 3;
switch (i & 1)
{
case EVEN: printf("Even");
break;
case ODD: printf("Odd");
break;
default: printf("Default");
}
return 0;
}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Even

Even

Odd

Odd

Default

Default

Compile time error

Compile time 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!"]

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%