Sunday, July 10, 2016

Sum of Three Numbers Using C++

A simple program that I wrote using C++ as my programming language that will compute the sum of three numbers using functions and structure. The code is very simple and easy to understand.

Add me at Facebook my address  is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.


Program Listing

#include <iostream>

using namespace std;

struct num {
     int value[3];
 };


int addition(num a)
 {
     return(a.value[0] +
            a.value[1] +
            a.value[2]);
 }



 main() {
        num b;
        cout << "\t Sum of Three Numbers ";
        cout << "\n\n";
        cout << "Enter three numbers : ";
        cin >> b.value[0] >> b.value[1] >> b.value[2];
        cout << "\n\n";
        cout << "The sum is "  <<addition(b);
        cout << "\n\n";
        system("pause");
 }

No comments:

Post a Comment