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

a = a + b;
                      b = a - b;

                      a = a - b;
                       cout<< "Values of a and b after swapping are " << a << " and " <<
                        b << ".";
                      getch();
                  }
                  The output of the above program is displayed as follows:

                                        DOSBox 0.74, Cpu speed: max 100% cycles, Frameskip 0, program:   TC
                                     Values of a and b before swapping are 15 and 25.
                                     Values of a and b after swapping are 25 and 15._


                  Program 4: To calculate the area of a circle of radius 5 cm.

                  #include<iostream.h>
                  #include<conio.h>
                  void main()
                  {
                      clrscr();
                      int radius = 5;
                                                                                 DOSBox 0.74, Cpu speed: max 100% cycles,
                      float pi = 3.14, area = 0;                             Area of circle is: 78.5_
                      area = pi * radius * radius;
                      cout<<"Area of circle is: "<<area;
                      getch();
                  }

                      Recap



                          A  character  set  refers  to  the  letters,  digits  and  special  symbols  that  can  be  used  to  write
                         programs in C++ language.

                         Tokens are the smallest individual units of a C++ program.
                         Keywords are special words in C++ that have a fixed meaning and cannot be used as variable
                         names.
                         A data type defines the type of value a variable can store.
                         Primitive data types are built-in or predefined data types.

                         Variables are memory locations used to store values.
                         A constant is a fixed value which does not change during the program execution.
                         C++ allows some special characters in its coding called delimiters or punctuators.

                         Operator is a symbol that performs operations on variables and values, such as arithmetic,
                         comparison, or logical operations.




                   20
                          Touchpad MODULAR (Ver. 2.0)
   17   18   19   20   21   22   23   24   25   26   27