Skip to content

Instantly share code, notes, and snippets.

@jesuscmadrigal
Created September 14, 2017 23:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jesuscmadrigal/41401324bf72cbd1a59206ca7c48987c to your computer and use it in GitHub Desktop.
Save jesuscmadrigal/41401324bf72cbd1a59206ca7c48987c to your computer and use it in GitHub Desktop.
On to functions
#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