Computer Science MCQs Programming C++ Sample 01
1.
Loop that evaluates
its test expression before each repetition
is a(n) ____ loop.
a.
For Loop
b. While Loop
c.
Do-While Loop
d.
All
2.
A loop
that evaluates its test
expression after each repetition is a(n) ____
loop.
a.
For Loop
b.
While Loop
c.
Do-While Loop
d.
All
3.
A loop
that does not
have a way of stopping is a(n) ____ loop.
a.
Counter Loop
b.
Infinite
Loop
c.
Accumulator Loop
d.
Nested Loop
4.
The loop
is ideal for situations that require
a counter.
a. For
Loop
b. While
Loop
c. Do-While
Loop
d. All
5.
The loop
always iterates at least
once.
a. For Loop
b. While
Loop
c. Do-While
Loop
d. All
6.
The _____
and _____ loops will not iterate at all if their test expressions
are false to start with.
a.
For
Loop and Do-While Loop
b.
For Loop and While Loop
c.
While Loop and Do-While
Loop
d.
None of these
7.
A loop
that is inside another is called a(n)
____ loop.
a. Counter
Loop
b. Infinite
Loop
c. Accumulator
Loop
d. Nested
Loop
8.
The ____
statement causes a loop to
terminate immediately.
a.
Continue
b.
Break
c.
Exit
d.
Default
9.
The statement
causes a loop to
skip the remaining statements in the
current iteration.
a. Continue
b. Break
c. Exit
d. Default
10.
How many lines will each of
the following while loops display?
int count = 1 ;
while (count< 15)
{
cout << "My favorite day is Sunday \n";
count = count + 2;
}
a.
15
b.
14
c.
7
d.
8
11.
What will
each of the following program segments display?
int count = 0 , number= 0 , limit = 4 ;
do
{
number += 2 ;
count ++ ;
} while (count< limit );
cout <<number<<" " <<count<< endl
;
a. 8 4
b. 0 4
c.
2
8
d. 2 1
12.
How many total stars
will be displayed by each of the
following program segments?
for (int row = 0; row< 10; row++)
{
for (int star = 0; star< 5 ; star++)
{
cout << '*';}
cout << endl ;
}
a.
50
b.
36
c.
15
d.
infinite
13.
while(1)
{}
is same as;
a.
for(int i=1;i<=1;i++)
b.
for(;;)
c.
for(int 0=1;i<=1;i++)
d.
no match with for loop
14.
What will be the output of the
following program
int x=-3, y=0;
while(x<0)
{
x++;
y--;
}
if (x == y)
Cout<<(x + --y);
else
Cout<<(x + ++y);
a. -2
b.
-3
c.
0
d.
1
e.
-1
15.
What will be the output of the above
program
main()
{
int x = 5;
do
{
Cout<<(x*x);
} while ((x == 0));
}
a.
5*5
b.
55
c. 25
d.
5
e.
No
output will show condition is false
16. How
many times “IMCG F-/2” will print?
main()
{
while(1)
cout<<“ IMCG F-/2”;
}
a.
One
b.
Zero
c.
Infinite
d.
10
e.
Error
in program
17.
What will be the output of the
following program
char i;
for (i = 65; i <= 70;
i++)
{
cout<<(i+1);
}
a.
656667686970
b.
666768697071
c.
ABCDEF
d.
651661671681691701
18.
Predict Output with the help of
dry-run of the given code.
#include <iostream>
using namespace std;
main()
{
int i,j; char ch='A';
for(i=1;i<=5;i++)
{
for(j=1;j<=5;j++)
{
cout<<ch<<"
";
ch++;
}
cout<<"\n";
}
A |
B |
C |
D |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|
thank you your post is very nice
ReplyDeleteC++ proogramming sample
Computer science mcq
Computer science notes
Computer teacher
Computer online test in hindi
Computer science current affairs