Sail E0 Webinar

MCQs

Total Questions : 10
Question 1.

Which looping process is best used when the number of iterations is known?


  1.    for
  2.    while
  3.    do-while
  4.    all looping processes require that the iterations be known
 Discuss Question
Answer: Option A. -> for

None.


Question 2.

How many types of loops are there?


  1.    4
  2.    2
  3.    3
  4.    1
 Discuss Question
Answer: Option A. -> 4

There are four types of loop. They are while, do while, nested, for loop.


Question 3.


What is the output of this program?


1.
#include
2.
using namespace std;
3.
int main()
4.
{
5.
int i;
6.
for (i = 0; i < 10; i++);
7.
{
8.
cout
  1.    0123456789
  2.    10
  3.    012345678910
  4.    compile time error
 Discuss Question
Answer: Option B. -> 10

for loop with a semicolon is called as body less for loop. It is used only for incrementing the 

variable values. So in this program the value is incremented and printed as 10.
Output:
$ g++ stat2.cpp
$ a.out
10


Question 4.


What is the output of this program?


1.
#include
2.
using namespace std;
3.
int main()
4.
{
5.
int n = 15;
6.
for ( ; ;)
7.
cout
  1.    error
  2.    15
  3.    infinite times of printing n
  4.    none of the mentioned
 Discuss Question
Answer: Option C. -> infinite times of printing n

There is not a condition in the for loop, So it will loop continuously.


Question 5.


What is the output of this program?


1.
#include
2.
using namespace std;
3.
int main()
4.
{
5.
int a = 10;
6.
if (a < 15)
7.
{
8.
time:
9.
cout
  1.    1010
  2.    10
  3.    infinitely print 10
  4.    compile time error
 Discuss Question
Answer: Option D. -> compile time error

Because the break statement need to be presented inside a loop or a switch statement.


Question 6.

The destination statement for the goto label is identified by what label?


  1.    $
  2.    @
  3.    *
  4.    :
 Discuss Question
Answer: Option D. -> :

None.


Question 7.

The switch statement is also called as?


  1.    choosing structure
  2.    selective structure
  3.    certain structure
  4.    none of the mentioned
 Discuss Question
Answer: Option B. -> selective structure

The switch statement is used to choose the certain code to execute, So it is also called as 

selective structure.


Question 8.


What is the output of this program?


1.
#include
2.
using namespace std;
3.
int main ()
4.
{
5.
int n;
6.
for (n = 5; n > 0; n--)
7.
{
8.
cout
  1.    543
  2.    54
  3.    5432
  4.    53
 Discuss Question
Answer: Option A. -> 543

Inthis program, We are printing the numbers in reverse order but by using break statement we 

stopped printing on 3.
Output:
$ g++ stat.cpp
$ a.out
543


Question 9.

The if..else statement can be replaced by which operator?


  1.    Bitwise operator
  2.    Conditional operator
  3.    Multiplicative operator
  4.    none of the mentioned
 Discuss Question
Answer: Option B. -> Conditional operator

In the conditional operator,it will predicate the output using the given condition.


Question 10.

How many sequence of statements are present in c++?


  1.    4
  2.    3
  3.    5
  4.    6
 Discuss Question
Answer: Option C. -> 5

There are five sequence of statements. They are Preprocessor directives,Comments,Declarations,

Function Declarations,Executable statements.


Latest Videos

Latest Test Papers