fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int a, b, sum = 0, sub = 0, mul = 0, mod = 0;
  7. double div = 0.0;
  8.  
  9. cout << "Enter 1st number: ";
  10. cin >> a;
  11.  
  12. cout << "Enter 2nd number: ";
  13. cin >> b;
  14.  
  15. sum = a + b;
  16. sub = a - b;
  17. mul = a * b;
  18. div = static_cast<double>(a) / b; // typecast for precise division
  19. mod = a % b;
  20.  
  21. cout << "Sum : " << sum << endl;
  22. cout << "Subtraction : " << sub << endl;
  23. cout << "Multiplication : " << mul << endl;
  24. cout << "Division : " << div << endl;
  25. cout << "Modulus : " << mod << endl;
  26.  
  27. return 0;
  28. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
Enter 1st number: Enter 2nd number: Sum         : 779857785
Subtraction : 779847367
Multiplication : -786993632
Division    : 149713
Modulus     : 2768