Thursday, November 2, 2017

Product of Two Numbers Using Function in C++

A very simple program that I wrote that will ask the user to give two numbers and then our program will compute the product using function in C++. The code is very simple and easy to understand it also shows you how to use one dimensional array in C++.

I am currently accepting programming work kindly contact me in the following email address for further details. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental is (034) 4335675.



Program Listing


 #include <iostream>
 #include <iomanip>

  using namespace std;

 // Global variable

  int val[2],product=0;

   void accept() {
       cout << "Enter two numbers : ";
       cin >> val[0] >> val[1];
   }

   int solve(int a, int b)
    {
     return(a*b);
    }

    void display()
    {

       cout << setw(50) <<"The product is "
            << solve(val[0],val[1])
            << ".";
    cout << "\n\n";
    system("pause");
    }

main() {
    accept();
    display();
}

No comments:

Post a Comment