Our first assigment was to make a program that asked the user for two numbers and then showed the sum, difference, product, integer quotient and remainder of that numbers.
The code I made is very simple, I just included an additional library (<math.h>) to use the fabs function whe dividing the numbers, because the instructions indicated a difference, and differences are always absolute.
This is my program:
#include <iostream> #include <math.h> using namespace std; int main() { int X, Y; cout << "Write an integer number: "; cin >> X; cout << "Give me another integer number: "; cin >> Y; cout << "Sum = " << X+Y << endl; cout << "Difference = " << fabs(X-Y) << endl; cout << "Product = " << X*Y << endl; cout << "Division (first/second) = " << X/Y << endl; cout << "Remainder of division = " << X%Y << endl; return 0; }