On to functions

So I´ve been absent for a while, but here I am again. I did this program like two weeks ago, but I didn´t post anything, anyways, this program was really easy, I used the original code of my first program, I just created the functions and applied them into the program.

Here´s the code:

#include <iostream>
using namespace std;
int sum(int x, int y){
int num=x+y;
return num;
}
int res(int x, int y){
int num=x-y;
return num;
}
int tim(int x, int y){
int num=x*y;
return num;
}
int div(int x, int y){
int num=x/y;
return num;
}
int main ()
{
int x,y;
cout<<«hi, enter the first number (X):»;
cin>>x;
cout<<«Enter the second number (Y):»;
cin>>y;

cout<<«X+Y=»<<sum(x,y)<<endl;
cout<<«X-Y=»<<res(x,y)<<endl;
cout<<«X*Y=»<<tim(x,y)<<endl;
cout<<«X/Y=»<<div(x,y )<<endl;
return 0;
}

and here’s how it works:

onto

Deja un comentario