--Originally published at MarizProfile
In this activity I had to use for the first time formulas outside of the main, (not like in the last activities where all the processes took place inside of the main). I used formulas to get the result of several arithmetic operations, like a sum, a subtraction, a multiplication, a division and the remainder of it. To print those results I used a “cout” for each of the operations mentioned, and I returned to call the formula previously written above the main, writing inside the parenthesis the variables used in that formula.
-> For example (division):
int D (int x, int y){
return (x/y);
}
int x, y;
using namespace std;
int main(){
cout<< “The result of the division of those two numbers is: ” << D(x,y) << endl;
}