Question 1

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

#include 
int a=10;
int main ()
{
int a = 20;
cout <<::a;
return 0;
}

10

10

20

20

::10

::10

::20

::20

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 following programs?



#include >iostream>
using namespace std;
int main()
{
cout <<P"includehelp.com";
return 0;
}

Compile Time Error

Compile Time Error

Run Time Error

Run Time Error

includehelp.com

includehelp.com

None of these.

None of these.

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

Please login to submit your explanation

Question 3

Time: 00:00:00
Which header file is required to use setw() function?

conio.h

conio.h

iostream.h

iostream.h

stdlib.h

stdlib.h

iomanip.h

iomanip.h

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

Please login to submit your explanation

Question 4

Time: 00:00:00
Which is the correct answer regarding '\n' and endl?

Both are same.

Both are same.

'\n' and endl both are used to print new line but endl flushes the buffer after printing new line.

'\n' and endl both are used to print new line but endl flushes the buffer after printing new line.

'\n' and endl both are used to print new line but '\n' flushes the buffer after printing new line.

'\n' and endl both are used to print new line but '\n' flushes the buffer after printing new line.

'\n' used in C programming while endl used in C++ programming.

'\n' used in C programming while endl used in C++ programming.

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

Please login to submit your explanation

Question 5

Time: 00:00:00
To print out a and b given below, which of the following printf() statement will you use?
#include
float a=3.14;
double b=3.14;

printf("%f %lf", a, b);

printf("%f %lf", a, b);

printf("%Lf %f", a, b);

printf("%Lf %f", a, b);

printf("%Lf %Lf", a, b);

printf("%Lf %Lf", a, b);

printf("%f %Lf", a, b);

printf("%f %Lf", a, b);

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

Please login to submit your explanation

Question 6

Time: 00:00:00
Will the following program work.


#include<stdio.h>
int main()
{
int n=5;
printf("n=%*d\n", n, n);
return 0;
}

Yes

Yes

No

No

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

Please login to submit your explanation

Question 7

Time: 00:00:00
What will be the output of this code?
#include <iostream>
using namespace std;
int main()
{
int a=-5;
int k=(a++,++a);
printf("%d\n",k);
return 0;
}

-3

-3

5

5

-6

-6

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

Please login to submit your explanation

Question 8

Time: 00:00:00
What will be the output of the following code
#include <iostream>
using namespace std;
int main()
{
if(7&8)
printf("Honesty");
if((~7 & 0x000f)==8)
printf("is the best policy\n");
}

Honesty

Honesty

No output

No output

is the best policy

is the best policy

error

error

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

Please login to submit your explanation

Question 9

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

#include <iostream>
using namespace std;
int main()
{
int b=5&4&6;
printf("%d",b);
}

4

4

2

2

3

3

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 of the following code

char * getString () 
{
char *str = "Nice test for strings";
return str;
}
int main ()
{
printf ("%s", getString ());
getchar ();
return 0;
}

Nice test for strings

Nice test for strings

for strings

for strings

No output

No output

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

Buy TCS NQT Paid Materials

Paid Materials TCS NQT

Join TCS NQT Online Classes

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.

Comments