You will go back and do WSQ01 – Fun with Numbers again.
But this time, write a function for each calculation. Each function should define two parameters (in this example of type int) and return the correct value as an integer as well.
You main program needs to ask the user for the input and then call each function to calculate the answer for each of the parts.
Progress:
fist we need to search wsq01 homework for remind how do this exercise, but now we have to change de variables into a functions.
Then we had to look for reliable sources on the subject of functions so as to know which methodology to carry out this challenge, finally as we did this task previously, we just have to change that part of functions.
CODE:
include <iostream>
using namespace std;
int sum(int x, int y){
return (x+y);
}
int Difference (int x, int y){
return (x-y);
}
int Product (int x, int y){
return (x*y);
}
int Division (int x, int y){
return (x/y);
}
int Remainder (int x, int y){
return (x%y);
}
int main()
{
int x,y;
cout << “este programa tiene una funcionalidad similar al WSQ01 pero ahora todo integrado en funciones” << endl;
cout << “teclea el primer numero a evaluar” << endl;
cin >> x;
cout << “teclea el segundo numero a evaluar” << endl;
cin >> y;
int r1 = sum(x,y);
int r2 = Difference(x,y);
int r3 = Product(x,y);
int r4 = Division(x,y);
int r5 = Remainder(x,y);
cout << “la suma de los dos numeros es: ” << r1 << endl;
cout << “la resta de los dos numeros es: ” << r2 << endl;
cout << “la multiplicacion de los dos numeros es: ” << r3 << endl;
cout << “la
Continue reading "WSQ05 – On To Functions!!!!!" →