Question 1

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

#include
using namespace std;
int main()
{
int y=30;
while (y > 10)
{
y = y - 4;
}
cout<<y;

return 0;
}

10

10

8

8

20

20

Compiler error

Compiler error

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
using namespace std;
int main()
{
int num = 20;
if(num > 5)
{
cout<< num -6;
}
else{
cout<<3*(num + 1);
}

return 0;
}

22

22

14

14

23

23

3

3

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

Please login to submit your explanation

Question 3

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

#include
using namespace std;
int main()
{
int n = 50;
if(n == 4)
{
cout<< n-6;
}
else{
cout<<3*(n+1);
}

return 0;
}

63

63

128

128

23

23

153

153

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

Please login to submit your explanation

Question 4

Time: 00:00:00
What will be the output of the following code.
#include
using namespace std;
int main()
{
int x = 201, y=1001;
if(x > 100)
{
cout<< y-x;
}
else{
cout<<3*(x+1);
}

return 0;
}

204

204

345

345

1001

1001

1000

1000

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

Please login to submit your explanation

Question 5

Time: 00:00:00
What will be the output of the following code
#include
using namespace std;
int main()
{
int a=230, b= 130;
a=a+1;
b=b-1;
a=a/b;
b=b/a;
cout<<a<<" "<<b;
}

5 78

5 78

64 1

64 1

1 345

1 345

1 129

1 129

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

Please login to submit your explanation

Question 6

Time: 00:00:00
What will be the output of the following code?
#include
using namespace std;
int main()
{
int p =1,q=2,r=3;
*( ( p+1==1) ? &q : &p)= p? q : r;
printf("%d, %d, %d \n", p , q, r );
return 0;
}

1 2 3

1 2 3

2 2 3

2 2 3

0 2 2

0 2 2

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 7

Time: 00:00:00
What will be the output of the following code?
#include
using namespace std;
int main()
{
int a = 678, b=40;
float c;
c = a / b;
cout<<c;
return 0;
}

16

16

16.4

16.4

1.64

1.64

164

164

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
int main()
{
int x = 2;
(x & 1) ? printf(“true”) : printf(“false”);
return 0;
}

true

true

false

false

Error

Error

zero

zero

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
using namespace std;
int main()
{
int a = 48, b = 6;
printf("a^b = %d", a^b);
return 0;
}

3

3

54

54

78

78

49

49

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
#include
int main()
{
int a = 48, b = 4;
printf("a|b = %d\n", a|b);
return 0;
}

52

52

89

89

43

43

16

16

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.