Page 75 - Modular_V2.0_C++_Flikpbook
P. 75

D.   Short answer type questions.

                      1.  What is the purpose of looping statements?
                      2.  Write the names of all the jump statements provided by C++.

                      3.  Write the syntax to declare a variable inside the for loop.

                      4.  What is the use of goto statement in C++?

                 E.   Long answer type questions.
                      1.  Differentiate between break and continue statements.

                      2.  Write any two differences between while and do-while loops.

                      3.  Can a while loop contain another while loop? If yes, write the syntax to do the same.

                 F.   Find the output of the following codes:
                      1.  int num = 8;

                         for(int i = 1; i <= num; i++)

                         {

                             if(i==5)

                                 continue;
                             else

                                 cout<<i << “\n”;

                         }
                      2.   int i = 1;                                       3.   int sum = 0;

                          while(i <5)                                            for(int i = 0; i <= 10; i++)
                          {                                                     {

                                  cout<< i;                                           sum = sum + i;
                                  i = i * 2;                                          cout<< sum;
                          }                                                     }
                      4.  int r = 5, c = 3;

                            for(int i = 1; i <= r; ++i)
                          {

                                  for(int j = 1; j <= c; ++j)
                                  {
                                         cout<< "*  ";

                                  }
                                cout<<"\n";

                          }


                                                                                                                  73
                                                                                                         Loops
   70   71   72   73   74   75   76   77   78   79   80