In this article I would like to share with you a sample program that I wrote while I'm still learning how to program using pointers as my data structure. I called this program addition of three numbers using pointers what the program does is to ask the user to enter three numbers and then our program will compute for the sum of the three number being provided by our user.
Feel free to use my code in your programming projects at school or work. If you have some questions please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
People here in the Philippines can reach me at my mobile number 09173084360.
Thank you very much and Happy Programming.
Program Listing
#include <iostream>
using namespace std;
int addition(int *a, int *b, int *c)
{
return(*a + *b + *c);
}
main() {
int x=0,y=0,z=0;
cout << "Addition Program";
cout << "\n\n";
cout << "Enter three numbers : ";
cin >> x >> y >> z;
cout << "\n\n";
cout << "The sum of three numbers is "
<< addition(&x,&y,&z)
<<".";
cout << "\n\n";
system("pause");
}
No comments:
Post a Comment