NTT Data Iteration, Recursion, Decision Quiz-1

Question 1

Time: 00:00:00
Which loop is especially useful when you process a menu selection?

while

while

do-while

do-while

for

for

switch

switch

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

Please login to submit your explanation

Question 2

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

#include<stdio.h>

int main()

{

  int j=50;

  while(true)

  {

    if(j<10)

      break;

    j=j-10;

  }

  printf("j is %d", j);

}

Error

Error

No output

No output

j is 0

j is 0

j is 50

j is 50

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

Please login to submit your explanation

Question 3

Time: 00:00:00
In the while and do-while loops, Which statement causes control to be transferred directly to the conditional expression that controls the loop?

break

break

pause

pause

start

start

continue

continue

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

Please login to submit your explanation

Question 4

Time: 00:00:00
How many times below for loop will be executed ?

 

#include<stdio.h>

int main()

{

    int i=0;

    for(;;)

        printf("%d",i);

    return 0;

}

1 time

1 time

0 time

0 time

10 times

10 times

Infinite times

Infinite times

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

Please login to submit your explanation

Question 5

Time: 00:00:00
Find the output of the following program.

#include<stdio.h>

int main()

{

    char str[] = "Smaller";

    int a = 100;

    printf(a > 10 ? "Greater" : "%s", str);

    return 0;

}

 

Compilation Error

Compilation Error

Greater  

Greater  

Smaller

Smaller

100

100

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

Please login to submit your explanation

Question 6

Time: 00:00:00
Time Complexity of this program:

def f():

       ans = 0

       for i = 1 to n:

              for j = 1 to log(i):

                      ans += 1

      print(ans)

O(n)  

O(n)  

O(nlogn)  

O(nlogn)  

O(n2)  

O(n2)  

O(n3)

O(n3)

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

Please login to submit your explanation

Question 7

Time: 00:00:00
 How many times will this loop execute?

#include<stdio.h>

int main()

{

int i;

for(i=0;i<10;i++)

{

printf("%d\n",i++);

i=++i;

}

return 0;

}

10

10

5

5

4  

4  

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

Question 8

Time: 00:00:00
How many times will this loop execute?

#include<stdio.h>

int main()

{

int i=1;

for(;i<10;i=i/i)

{

printf("%d\n",i);

}

return 0;

}

10

10

5    

5    

4  

4  

Infinite times

Infinite times

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

Please login to submit your explanation

Question 9

Time: 00:00:00
How many times will this loop execute?

#include<stdio.h>

int main()

{

int max = 5;

int i = 0;

for(;;)

{

i++;

if(i> max)

break;

printf("i = %d\n",i);

}

return 0;

}

2

2

5  

5  

4  

4  

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

Question 10

Time: 00:00:00
What will be the output?

#include<stdio.h>

int main()

{

int max = 5;

int c = 0;

for(; c <max;c++);

{

         printf("%d ",c);

}

printf("END\n");

return 0;

}

0 1 2 3 4 End

0 1 2 3 4 End

1 2 3 4 5 End

1 2 3 4 5 End

5 End  

5 End  

Error  

Error  

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

Please login to submit your explanation

["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%

Get over 200+ Courses under One Subscription

mute

Don’t settle Learn from the Best with PrepInsta Prime Subscription

Learn from Top 1%

One Subscription, For Everything

The new cool way of learning and upskilling -

Limitless Learning

One Subscription access everything

Job Assistance

Get Access to PrepInsta Prime

Top Faculty

from FAANG/IITs/TOP MNC's

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others.