fork(1) download
  1. //@Author Damien Bell
  2. #include <iostream>
  3. #include <cmath>
  4. using namespace std;
  5. int main(){
  6. int choice=0;
  7. double x=0, y=0;
  8.  
  9.  
  10. cout <<"Press 1 for Addition" << endl << "Press 2 for Subtraction" <<endl << "Press 3 for multiplication" <<endl;
  11. cout <<"Press 4 for division" << endl << "Press 5 for raising a number to a power" <<endl <<"Press 6 to find the remainder of a number";
  12. cout <<"\nEnter your selection now: ";
  13. cin >> choice;
  14.  
  15. cout <<"\nEnter the first value to use: ";
  16. cin >>x;
  17. cout <<"\nEnter the second value to use: ";
  18. cin >>y;
  19.  
  20. switch(choice){
  21. case 1:{
  22. cout << "\nThe sum of " <<x << " + " << y << " = " << x+y;
  23. break;
  24. }
  25. case 2:{
  26. cout << "\nThe difference of " <<x << " - " << y << " = " << x-y;
  27. break;
  28. }
  29. case 3:{
  30. cout << "\nThe product of " <<x << " * " << y << " = " << x*y;
  31. break;
  32. }
  33. case 4:{
  34. cout << "\nThe quotient of " <<x << " / " << y << " = " << x/y;
  35. break;
  36. }
  37. case 5:{
  38. cout << "\nThe exponential value of " <<x << " ^ " << y << " = " << pow(x,y);
  39. break;
  40. }
  41. case 6:{
  42. cout << "\nThe remainder of " <<x << " / " << y << " = " << (int (x)%int (y));
  43. break;
  44. }
  45. default:{
  46. cout << "\nWhoops, something went wrong";
  47. break;
  48. }
  49. }//End switch
  50.  
  51.  
  52. return 0;
  53. }
Success #stdin #stdout 0s 2864KB
stdin
5
2
3
stdout
Press 1 for Addition
Press 2 for Subtraction
Press 3 for multiplication
Press 4 for  division
Press 5 for raising a number to a power
Press 6 to find the remainder of a number
Enter your selection now: 
Enter the first value to use: 
Enter the second value to use: 
The exponential value of 2 ^ 3 = 8