Page 78 - Modular_V1.1_Flipbook
P. 78

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)
                  {
                                                                                      Output:
                        return num1 + num2;
                                                                                      Enter first number: 9
                  }                                                                   Enter second number: 2
                  int sub(int num1, int num2)                                         The sum of two numbers is: 11
                  {                                                                   The difference of two numbers is: 7
                                                                                      The product of two numbers is: 18
                        return num1 - num2;
                                                                                      The division of two numbers is: 4
                  }
                                                                                      The remainder after  dividing two
                  int multi(int num1, int num2)                                       numbers is: 1

                  {
                        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;
                        cout<<”Enter a number: “;
                        cin>>num;



                  76      Touchpad MODULAR (Version 1.1)-X
   73   74   75   76   77   78   79   80   81   82   83