--Originally published at Programming the city
Hello people, today I want to show you a code where the user types 2 integer numbers and the program makes the sum, difference, product, division and the reminder of the division between both numbers.
Here is the code:
#include <iostream>
using namespace std;
int main()
{
int num1, num2, sum, difference, product, division, reminder;
cout<<“Give me a number “;
cin>>num1;
cout<<“Give me one more number “;
cin>>num2;
sum=num1+num2;
difference=num1-num2;
product=num1*num2;
division=num1/num2;
reminder=num1%num2;
cout<<“The sum of the numbers you just gave me is “<<num1<<“+”<<num2<<“=”<<sum<<endl;
cout<<“The difference between the numbers you just gave me is “<<num1<<“-“<<num2<<“=”<<difference<<endl;
cout<<“The product of the numbers you just gave me is “<<num1<<“x”<<num2<<“=”<<product<<endl;
cout<<“The division of the numbers you just gave me is “<<num1<<“/”<<num2<<“=”<<division<<endl;
cout<<“The reminder of the integer division is “<<reminder<<endl;
return 0;
}
As you can see, I added the int variables for each math operation, you have to know that the name of the variables is up to you.
Then, you have to input everything you need to, for example the variable sum, you just have to type the two variables and between them, type +, and automatically it will make the sum. For the other operations, is the same path, but with different symbols(-,*,/,%).
Here is the evidence.
#WSQ 01
#TC1017