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

cout<<"The sum of two numbers is: "<<sum(n1, n2)<<"\n";
                      cout<<"The difference of two numbers is: "<<sub(n1, n2)<<"\n";

                      cout<<"The product of two numbers is: "<<multi(n1, n2)<<"\n";
                      cout<<"The division of two numbers is: "<<div(n1, n2)<<"\n";
                       cout<<"The  remainder after dividing two numbers is: "<<mod(n1,
                        n2)<<"\n";
                      getch();
                  }
                  int sum(int num1, int num2)

                  {
                      return num1 + num2;
                  }
                  int sub(int num1, int num2)

                  {
                      return num1 - num2;
                  }
                  int multi(int num1, int num2)
                  {
                      return num1 * num2;

                  }
                  int div(int num1, int num2)
                  {
                      return num1 / num2;

                  }
                  int mod(int num1, int num2)
                  {
                      return num1 % num2;
                  }

                     TYPES OF PARAMETERS AND ARGUMENTS

                  The parameters passed at the time of declaring a function are called formal parameters. On the
                  other hand, the parameters passed at the time of calling a function are called actual arguments.

                  Program 2: To display the table of a number input by the user.

                  #include<iostream.h>
                  #include<conio.h>
                  void table(int);
                  void main()
                  {
                      int num;
                      clrscr();
                   88
                          Touchpad MODULAR (Ver. 2.0)
   85   86   87   88   89   90   91   92   93   94   95