Saturday, July 1, 2017

Addition of Numbers Using Functions and Arrays in C++

A very simple program that I wrote during the time I'm still working as university professor to add the sum of three numbers using functions and one dimensional array in C++. I hope you will find my work useful.  Thank you.

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

My mobile number here in the Philippines is 09173084360.



Program Listing

#include <iostream>


 using namespace std;

int addition(int a, int b, int c)
{
    cout << "The sum of "
      << a << "," << b <<  " and "
      <<  c << " is "
      << (a + b + c) << ".";
}

main() {
    int a[2];
    cout << "\t\t ADDITION USING FUNCTION";
    cout << "\n\n";
    cout << "Enter a Value No. 1 ";
    cin >> a[0];
    cout << "Enter a Value No. 2 ";
    cin >> a[1];
    cout << "Enter a Value No. 3 ";
    cin >> a[2];
    cout << "\n";
    addition(a[0],a[1],a[2]);
    cout << "\n\n";
    system("pause");
}



No comments:

Post a Comment