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

D.   Short answer type questions.
                       1.  What are conditional statements?

                       2.  Define the if…else statement.
                       3.  Can ternary operator replace the if…else statement?
                       4.  Write the syntax of nested if statement.

                  E.   Long answer type questions.

                       1.  What is the purpose of if statement? Write the syntax of the if statement.
                       2.  Describe switch statement. What is the difference between if and switch statement?
                       3.  What is the purpose of default clause in a switch statement?
                       4.  Rewrite the following if-else segment using switch-case statement:

                           char code;
                           cin>> code;
                           if(code == 'A')
                           cout<< "Accountant";
                           else
                           if(code == 'C' || code = 'G')
                           cout<< "Grade IV";

                           else
                           if(code == 'F')
                           cout<< "Financial Advisor";
                       5.  Complete the following C++ program:
                           void main()
                           {
                               switch (draw)
                               {

                               case 'R' : cout<< "Draw rectangle";
                               break;
                               case 'C' : cout<< "Draw circle";
                               break;
                               case 'E' : cout<< "Draw ellipse";
                               break;
                               case 'P' : cout<< "Draw polygon";

                               break;
                               default : cout<< "Wrong choice";
                               }
                           }








                   54
                          Touchpad MODULAR (Ver. 2.0)
   51   52   53   54   55   56   57   58   59   60   61