--Originally published at Titel der Website
It is the same calculator like in #WSQ01 but now with declared Functions. The code is:
#include<iostream>
#include<cmath>
#include<cstdlib>
using namespace std;
int Addition (int number1,int number2){
int solution;
solution=number1+number2;
return solution;
}
int Numbdiff (int number1,int number2){
int solution;
if (number1 <= number2){
solution=number2 – number1;
}
else {
solution=number1 – number2;
}
return solution;
}
int product (int number1, int number2){
int solution;
solution = number1 * number2;
return solution;
}
int division (int number1, int number2){
int solution;
solution = number1 / number2;
return solution;
}
int remainder (int number1, int number2){
int solution;
solution = number1 % number2;
return solution;
}
int main(){
int zahl1;
int zahl2;
cout<<„I am doing calculations for you. Give me two numbers!“<<endl;
cout<<„Enter first number: „<<endl;
cin>>zahl1;
cout<<„Enter second number: „<<endl;
cin>>zahl2;
cout<<„The summ of the two numbers is: „<< Addition(zahl1,zahl2)<<endl;
cout<<„The difference between the two numbers is :“<<Numbdiff(zahl1,zahl2)<<endl;
cout<<„The product is :“<<product(zahl1,zahl2)<<endl;
cout<<„The quotient is: „<<division(zahl1,zahl2)<<endl;
cout<<„The remainder is: „<<remainder(zahl1,zahl2)<<endl;
}
And again it worked: