Created
September 14, 2017 23:52
-
-
Save jesuscmadrigal/41401324bf72cbd1a59206ca7c48987c to your computer and use it in GitHub Desktop.
On to functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cstdlib> | |
using namespace std; | |
int sum (int x,int y) | |
{ | |
int sum; | |
sum=x+y; | |
return sum; | |
} | |
int xminus (int x,int y) | |
{ | |
int xminus; | |
xminus=x-y; | |
return xminus; | |
} | |
int product (int x,int y) | |
{ | |
int product; | |
product=x*y; | |
return product; | |
} | |
int division (int x,int y) | |
{ | |
int division; | |
division=x/y; | |
return division; | |
} | |
int residuo (int x,int y) | |
{ | |
int residuo; | |
residuo=x%y; | |
return residuo; | |
} | |
int main () | |
{ int x,y,s,m,p,d,r; | |
cout<< "Today we´re working in functions." << endl; | |
cout<< "please choose the first integer: " << endl; | |
cin>> x; | |
cout<< "please choose the second integer: " << endl; | |
cin>> y; | |
s=sum(x,y); | |
m=xminus(x,y); | |
p=product(x,y); | |
d=division(x,y); | |
r=residuo(x,y); | |
cout<< "The result between " << x << " + " << y << " is: " << s << endl; | |
cout<< "The result between " << x << " - " << y << " is: " << m << endl; | |
cout<< "The result between " << x << " x " << y << " is: " << p << endl; | |
cout<< "The result between " << x << " / " << y << " is: " << d << endl; | |
cout<< "The result between " << x << " % " << y << " is: " << r << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment