fork(1) download
  1. int main () {
  2. int intValue, menuSelect,Results;
  3. intValue = 1;
  4. while (intValue > 0) {
  5. printf ("Enter a positive Integer\n: ");
  6. intValue = -99;
  7. scanf("%d", &intValue);
  8. if (intValue > 0) {
  9. printf ("Enter 1 to calculate Square, 2 to Calculate Cube, 3 to Calculate Shrink \n: ");
  10. scanf("%d", &menuSelect);
  11. if (menuSelect == 1) {
  12. Results = Square(intValue);
  13. printf("Square of %d is %d\n",intValue,Results);
  14. }
  15. else if (menuSelect == 2) {
  16. Results = Cube(intValue);
  17. printf("Cube of %d is %d\n",intValue,Results);
  18. }
  19. else if (menuSelect == 3) {
  20. Results = intValue / 2;
  21. printf("Shrink of %d is %d\n",intValue,Results);
  22. }
  23. else printf("Invalid menu item, only 1, 2, or 3 are accepted\n");
  24. }
  25. }
  26. return 0;
  27. }
  28. int Square(int value) {
  29. return value*value;
  30. }
  31. int Cube(int value) {
  32. return value*value*value;
  33. }
  34. int Shrink(int value) {
  35. return value/2;
  36. }
Success #stdin #stdout 0s 2172KB
stdin
10
1
10
2
10
3
-99
stdout
Enter a positive Integer
: Enter 1 to calculate Square, 2 to Calculate Cube, 3 to Calculate Shrink 
: Square of 10 is 100
Enter a positive Integer
: Enter 1 to calculate Square, 2 to Calculate Cube, 3 to Calculate Shrink 
: Cube of 10 is 1000
Enter a positive Integer
: Enter 1 to calculate Square, 2 to Calculate Cube, 3 to Calculate Shrink 
: Shrink of 10 is 5
Enter a positive Integer
: