Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 156 - CoreGPT(Podar)_Flipbook_C8
P. 156

    case 'O':
                               cout<<"Entered character is vowel";
                          break;
                          case 'o':
                              cout<<"Entered character is vowel";

                          break;
                          case 'U':
                              cout<<"Entered character is vowel";

                          break;
                          case 'u':
                              cout<<"Entered character is vowel";                 Enter a character: A
                          break;                                                  Entered character is vowel
                          default:

                              cout<<"Entered character is consonant";
                         }
                         getch();                                                 Enter a character: M

                      }                                                           Entered character is consonant
                       Clickipedia

                        The  expression  of  switch  statement  must  be  of  integer  or  character  type.  Floating-point
                        constants are not allowed.

                            LOOP STRUCTURES

                      Loops allow you to repeat a section of your program for a certain number of times. The repetition
                      continues until a condition is true. When the condition becomes false, the loop ends and control
                      passes to the statements following the loop. C++ provides three types of loops: for loop, while
                      loop and do-while loop.
                      The for Loop

                      The for loop executes a simple or compound statements for a fixed number of times or until a
                      condition becomes false. The syntax of the for statement is given below:

                      for(initialisation; condition; update)
                      {

                          statements;
                      }
                      Components of a for loop:

                          initialisation is a method to assign value to the variable(s) starting the loop (called loop
                          variables). Once the initialisation process is completed, it’s never evaluated again.

                    154     Premium Edition-VIII

| 151 152 153 154 155 156 157 158 159 160 161 |