fork download
  1. #include <stdio.h>
  2.  
  3. int Square (int value);
  4. double Shrink (double value);
  5.  
  6. int main()
  7. {
  8. int intValue, doubleValue, menuSelect, Results;
  9. intValue = 1;
  10. doubleValue = 1;
  11.  
  12. while(intValue > 0)
  13. {
  14. printf ("Enter a positive Interger:\n ");
  15. scanf("%d", &intValue);
  16.  
  17. if(intValue > 0);
  18. {
  19. printf("Enter 1 to calculate Square, 2 to calculate Shrink:\n ");
  20. scanf("%d", &menuSelect);
  21.  
  22. if(menuSelect == 1)
  23. {
  24. Results = Square(intValue);
  25. printf("Square of %d is %d\n", intValue, Results);
  26. }
  27.  
  28. else if (menuSelect == 2)
  29. {
  30. Results = Shrink(doubleValue);
  31. printf("Shrink of %d is %f\n", doubleValue, Results);
  32. }
  33.  
  34. else
  35. printf("Invalid menu item, only 1 or 2 is accepted\n");
  36. }
  37. }
  38. return 0;
  39. }
  40.  
  41. int Square (int value)
  42. {
  43. return value*value;
  44. }
  45.  
  46. double Shrink (double value)
  47. {
  48. return value/2;
  49. }
  50.  
  51.  
Success #stdin #stdout 0s 9432KB
stdin
10
1
35
2
-1
stdout
Enter a positive Interger:
 Enter 1 to calculate Square, 2 to calculate Shrink:
 Square of 10 is 100
Enter a positive Interger:
 Enter 1 to calculate Square, 2 to calculate Shrink:
 Shrink of 1 is 0.000000
Enter a positive Interger:
 Enter 1 to calculate Square, 2 to calculate Shrink:
 Shrink of 1 is 0.000000