Out of Numbers

--Originally published at PZ

This was a very easy program because we had to use the different things that we have seen la de loops and that things with simple functions like sum, product, etc.

This helped me a lot to understand the use of the ints, the structure that they must have and the way they work because. To be honest I didnt search anywhere because I just used the information that Ken gave us, principally the structure of the int and then I add the different variables.

include <iostream>
using namespace std;
int sum(int base, int limit);
int resta(int base, int limit);
int mul(int base, int limit);
int div(int base, int limit);
int rem(int base, int limit);
int main()
{
int a, b, x;
cout << “Please give the first number “;
cin >> a;
cout << “Please give me the second number”;
cin >> b;
cout <<“The sum of “<<a<<” + “<<b<<” is:”<< sum(a, b)<<endl;
cout <<“The substraction of “<<a<<” – “<<b<<” is:”<< resta(a, b)<<endl;
cout <<“The product of “<<a<<” * “<<b<<” is:”<< mul(a, b)<<endl;

cout <<“The division of “<<a<<” / “<<b<<” is:”<< div(a, b)<<endl;
cout <<“The reminder of “<<a<<” / “<<b<<” is:”<< rem(a, b)<<endl;

 

return 0;
}

int sum(int a, int b)
{
int x ;
x=a+b;
return x;
}

int resta(int a, int b)
{
int x ;
x=a-b;
return x;
}

int mul(int a, int b)
{
int x ;
x=a*b;
return x;
}

int div(int a, int b)
{
int x ;
x=a/b;
return x;
}

int rem(int a, int b)
{
int x ;
x=a%b;
return x;
}