TCS Ninja Loops Quiz-1

Question 1

Time: 00:00:00
The output of the code below is
#include <stdio.h>
int a;
void main()
{
if (a)
printf(“Hello”);
else
printf(“world”);
}

Hello

Hello

World

World

compile time error

compile time error

none

none

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

Please login to submit your explanation

compile time error

Start

Question 2

Time: 00:00:00
The output of the code below is

#include <stdio.h>
void main()
{
int a = 5;
if (true);
printf(“hello”);
}

It will display hello

It will display hello

It will throw an error

It will throw an error

No Output

No Output

Depends on Compiler

Depends on Compiler

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

Please login to submit your explanation

true is not a keyword in C. So it gives error.

Start

Question 3

Time: 00:00:00
The output of the code below is
#include <stdio.h>
void main()
{
int a = 0;
if (a == 0)
printf(“hi”);
else
printf(“how are u”);
printf(“hello”);
}

hi

hi

how are you

how are you

hello

hello

hihello

hihello

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

Please login to submit your explanation

Start

Question 4

Time: 00:00:00
The following code ‘for(;;)’ represents an infinite loop. It can be terminated by.

break

break

exit(0)

exit(0)

abort()

abort()

all of the mentioned

all of the mentioned

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

Please login to submit your explanation

Start

Question 5

Time: 00:00:00
The correct syntax for running two variable for loop simultaneously is.

a) for (i = 0; i < n; i++) for (j = 0; j < n; j += 5)

a) for (i = 0; i < n; i++) for (j = 0; j < n; j += 5)

for (i = 0, j = 0;i < n, j < n; i++, j += 5)

for (i = 0, j = 0;i < n, j < n; i++, j += 5)

for (i = 0; i < n;i++){}

for (i = 0; i < n;i++){}

for (j = 0; j < n;j += 5){}

for (j = 0; j < n;j += 5){}

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

Please login to submit your explanation

Start

Question 6

Time: 00:00:00
Which for loop has range of similar indexes of ‘i’ used in for (i = 0;i < n; i++)?

for (i = n; i>0; i–)

for (i = n; i>0; i–)

for (i = n; i >= 0; i–)

for (i = n; i >= 0; i–)

for (i = n-1; i>0; i–)

for (i = n-1; i>0; i–)

for (i = n-1; i>-1; i–)

for (i = n-1; i>-1; i–)

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

Please login to submit your explanation

Start

Question 7

Time: 00:00:00
The output of this C code is?

#include <stdio.h>
void main()
{
int x = 0;
for (x < 3; x++)
printf(“Hello”);
}

Compile time error

Compile time error

Hello is printed thrice

Hello is printed thrice

Nothing

Nothing

Varies

Varies

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

Please login to submit your explanation

Start

Question 8

Time: 00:00:00
The output of this C code is?

#include <stdio.h>
void main()
{
double x = 0;
for (x = 0.0; x < 3.0; x++)
printf(“Hello”);
}

Run time error

Run time error

Hello is printed thrice

Hello is printed thrice

Hello is printed twice

Hello is printed twice

Hello is printed infinitely

Hello is printed infinitely

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

Please login to submit your explanation

Start

Question 9

Time: 00:00:00
The output of this C code is?

#include <stdio.h>
int main()
{
do
printf(“Inside while loop “);
while (0);
printf(“Outside loop\n”);
}

Inside while loop

Inside while loop

Inside while loop Outside loop

Inside while loop Outside loop

Outside loop

Outside loop

Infinite loop

Infinite loop

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

Please login to submit your explanation

Start

Question 10

Time: 00:00:00
The output of this C code is?

#include <stdio.h>
int main()
{
int i = 0;
do {
i++;
printf(“Inside while loop\n”);
} while (i < 3);
}

Inside while loop

Inside while loop

Outside while loop

Outside while loop

Depends on the compiler

Depends on the compiler

Compile time error

Compile time error

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

Please login to submit your explanation

Start

Question 11

Time: 00:00:00
Which of the following cannot be used as LHS of the expression in for (exp1 ;exp2 ; exp3) ?

Variable

Variable

Function

Function

typedef

typedef

macros

macros

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

Please login to submit your explanation

Start

Question 12

Time: 00:00:00
Which keyword can be used for coming out of recursion?

break

break

return

return

exit

exit

Both break and return

Both break and return

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

Please login to submit your explanation

Start

Question 13

Time: 00:00:00
The keyword ‘break’ cannot be simply used within:

do-while

do-while

if else

if else

for

for

while

while

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

Please login to submit your explanation

Start

Question 14

Time: 00:00:00
Which keyword is used to come out of a loop only for single iteration?

break

break

continue

continue

return

return

none

none

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

Please login to submit your explanation

Start

Question 15

Time: 00:00:00
The output of this C code is?

#include <stdio.h>
void main()
{
int i = 0;
if (i == 0)
{
printf(“Hello”);
break;
}
}

Hello is printed infinite times

Hello is printed infinite times

Hello

Hello

Varies

Varies

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/15

Accuracy

0%

Get Prepinsta Prime

Get all 200+ courses offered by Prepinsta

Never Miss an OffCampus Update

Get OffCampus Updates on Social Media from PrepInsta

Follow us on our Media Handles, we post out OffCampus drives on our Instagram, Telegram, Discord, Whatsdapp etc.

Get Hiring Updates
Amazon,Google,Delottie & 30+companies are hiring ! Get hiring Updates right in your inbox from PrepInsta

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.

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.

Get PrepInsta Prime Subscription

Get access to all the courses that PrepInsta offers, check the out below -

Companies

TCS, Cognizant, Delloite, Infosys, Wipro, CoCubes, KPMG, Amazone, ZS Associates, Accenture, Congnizant & other 50+ companies

Programming

Data Structures, Top 500 Codes, C, C++, Java Python & other 10+ subjects

Skills

Full Stack Web Development, Data Science, Machine Learning, AWS Cloud, & other 10+ skills and 20+ projects

Comments