Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 163 - CoreGPT(Podar)_Flipbook_C8
P. 163

    4.  What will be the output of the following code?
                           if(True)

                           cout<<"Hello";
                           else
                           cout<<"Hi";

                           a.  Hello                                        b.  Hi

                           c.  Hello Hi                                     d.  Nothing will print

                     B.  Fill in the blanks using the words given below:
                                                     Hints

                                                          Three, Infinite, break, true, Initializing

                        1.  …………………… a variable means to assign a value to the variable.
                        2.  In C++, the non-zero value is interpreted as …………………….

                        3.  …………………… can be used inside the switch body but cannot be used inside if body.
                        4.  C++ provides ……………….....…… types of loops.

                        5.  A loop that never ends is called an ……………….....…… loop.
                     C.  Write ‘T’ for true and ‘F’ for false.

                        1.  Equal sign is used to assign a value to a variable.                             ……………………
                        2.  The conditional operator is the only ternary operator available in C++.         ……………………

                        3.  The if…else statement is the simplest conditional statement.                    ……………………
                        4.  Continue statement breaks the loop.                                             ……………………

                        5.  Continue statement skips the current iteration of the loop.                     ……………………
                     D.  Answer the following questions:

                        1.  What are primitive data types?
                        2.  What is the difference between '/' and '%' operators?

                        3.  What are conditional statements?
                        4.  State any four variable naming conventions.
                        5.  Find the error in the following code and rewrite the correct code:

                              int time = 08;
                              if(time < 12)
                              {
                                  cout>>"Good morning.";

                              }
                               else if(time > 20)
                              {

                                                                                      Developing Programs in C++        161

| 158 159 160 161 162 163 164 165 166 167 168 |