Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 155 - CoreGPT(Podar)_Flipbook_C8
P. 155

    case value3:

                     // Statements;
                         break;
                     default:

                     // Statements for unmatched cases;
                     }
                     This syntax shows how the switch statement checks for a match among multiple cases and uses
                     break to stop execution after a match is found. If no case matches, the default case runs.

                     Program 6: To check whether the entered character is vowel or consonant.

                     #include<iostream.h>
                     #include<conio.h>

                     void main()
                     {
                         clrscr();
                         char ch;
                         cout<<"Enter a character: ";

                         cin>>ch;
                         switch (ch)
                         {

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

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

                         break;
                         case 'e':
                             cout<<"Entered character is vowel";
                                                                                          i = 1, j = 10
                         break;
                                                                                          i = 2, j = 9
                         case 'I':                                                        i = 3, j = 8
                             cout<<"Entered character is vowel";                          i = 4, j = 7
                                                                                          i = 5, j = 6
                         break;
                                                                                          i = 6, j = 5
                         case 'i':                                                        i = 7, j = 4
                                                                                          i = 8, j = 3
                             cout<<"Entered character is vowel";
                                                                                          i = 9, j = 2
                         break;                                                           i = 10, j = 1

                                                                                      Developing Programs in C++        153

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