Page 43 - DCAP404 _Object Oriented Programming
P. 43

Object-oriented Programming




                    Notes                        else
                                                 {
                                                        cout  <<  end1  <<  “input  character >  z  but  less  than  a”;
                                                 }
                                   else
                                   {
                                                 cout  <<  end1  <<  “Input  character  less  than  A”;

                                   }
                                   return  0;
                                   }
                                   The following program shows how the clarity of steps can be increased by using braces ({and})
                                   for enclosing parts of the code that follow an if or an else statement.

                                   #include  <inostream.h>
                                   int  main()
                                   {
                                          char  inp;
                                          cout  <<  “Enter  a  character:  “;
                                          cin  >>  inp;

                                          if  (inp  >=  ‘A’)
                                          {
                                                 if  (inp  <=  ‘z’)
                                                 {
                                                        cout  <<  end1  <<  “Uppercase”;
                                                 }
                                                 else  if  (inp  >=  ‘a’)
                                                 {
                                                        if  (inp  <=  ‘z’)

                                                        {
                                                               cout  <<  end1  <<  “Lowercase”;
                                                        }
                                                 }
                                          }
                                          return  0;
                                   }

                                   if  (circle)  {
                                                 scanf  (  ‘  &f‘  ,    &  radius);
                                                 area  =  3.  14159  *  radius    *  radius;




          36                                LOVELY PROFESSIONAL UNIVERSITY
   38   39   40   41   42   43   44   45   46   47   48