Loop in C++ MCQs Exercise I

Ques 1 Loop


What is the output of following code?


int main() 
{
    int i=1,x=1;
    do
    {
      if(i%5==0)
      {
        cout<<x;
        x++;
      }
      ++i;
    }while(i<10);
    cout<<x;
    return 0;
}

A 1
B 12
C 2
D 123

Ques 2 Loop


What is the output of fallowing code?


int main() 
{
  int i=0,x=1;
  for(i=1;i<10;i*=2)
  {
     x++;
     cout<<x;
  }
  cout<<x;
  return 0;
}

A 23455
B 23445
C 23345
D 23454

Ques 3 Loop


How many types of "SmallCode" in the output screen?


int main()
{
  for(int i=0; i< 5; i++);
	 cout<<"smallcode.com";
  return 0;
}

A 0
B 1
C 4
D 5

Ques 4 Loop


What is the output of following code?


int main()
{
  int x = 10;
  while (x>0)
    x--;
    cout<<x;
  return 0;
}

A 987654321
B 9876543210
C 9
D 0