Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 142 - CoreGPT(Podar)_Flipbook_C8
P. 142

    Operator        Name                       Description                      Example        Output
                                                                                                (a = 11, b = 4)
                           +       Addition         Adds two operands.                               a + b          15

                            -      Subtraction      Subtracts the right operand from the left        a - b           7
                                                    operand.
                            *      Multiplication Multiplies both operands.                          a * b          44
                            /      Division         Divides    the    numerator      by    the       a / b           2
                                                    denominator. Returns the quotient.

                           %       Modulus          Divides the numerator by the denominator         a % b           3
                                                    and returns the remainder.
                      Program 1: To perform arithmetic operations.

                      #include<iostream.h>
                      #include<conio.h>
                                                                             Addition result is : 25
                      void main()
                                                                             Subtraction result is : 15
                      {
                                                                             Multiplication result is : 100
                          clrscr();                                          Division result is : 4
                          int a, b, sum, sub, mul, divs;
                          a = 20, b= 5;

                          sum = a + b;

                          cout<<"Addition result is : "<<sum<<" \n";

                          sub = a - b;
                          cout<<"Subtraction result is : "<<sub<<" \n";

                          mul = a * b;
                          cout<<"Multiplication result is : "<<mul<<" \n";

                          divs = a / b;
                          cout<<"Division result is : "<<divs<<" \n";

                          getch();
                      }
                      Program 2: To convert the given time into hours and minutes.

                      #include<iostream.h>
                      #include<conio.h>
                      void main()
                      {

                    140     Premium Edition-VIII

| 137 138 139 140 141 142 143 144 145 146 147 |