fork download
  1. #include <stdio.h>
  2.  
  3. int Square(int value);
  4. int Cube(int value);
  5. double Shrink (double value);
  6. int main ()
  7.  
  8. {
  9.  
  10. /* variable definition: */
  11.  
  12. int intValue, menuSelect,Results;
  13.  
  14. intValue = 1;
  15.  
  16. // While a positive number
  17.  
  18. while (intValue > 0)
  19.  
  20. {
  21.  
  22. printf ("Enter a positive Integer\n: ");
  23.  
  24. scanf("%d", &intValue);
  25.  
  26. if (intValue > 0)
  27.  
  28. {
  29.  
  30. printf ("Enter 1 to calculate Square, 2 to calculate Cube, \
  31. 3 to calculate Half \n: ");
  32.  
  33. scanf("%d", &menuSelect);
  34.  
  35. if (menuSelect == 1)
  36.  
  37. {
  38.  
  39. // Call the Square Function
  40.  
  41. Results = Square(intValue);
  42.  
  43. printf("Square of %d is %d\n",intValue,Results);
  44.  
  45. }
  46.  
  47. else if (menuSelect == 2)
  48.  
  49. {
  50.  
  51. // Call the Cube function
  52.  
  53. Results = Cube(intValue);
  54.  
  55. printf("Cube of %d is %d\n",intValue,Results);
  56.  
  57. }
  58.  
  59. else if (menuSelect == 3)
  60.  
  61. {
  62. // Call the Shrink function
  63.  
  64. Results = Shrink(intValue);
  65.  
  66. printf ("Cube of %d is %lf \n", intValue,Results);
  67.  
  68. }
  69.  
  70. else
  71.  
  72. printf("Invalid menu item, only 1, 2, or 3 is accepted\n");
  73.  
  74. }
  75.  
  76. }
  77.  
  78. return 0;
  79.  
  80. }
  81.  
  82. /* function returning the Square of a number */
  83.  
  84. int Square(int value)
  85.  
  86. {
  87.  
  88. return value*value;
  89.  
  90. }
  91.  
  92. /* function returning the Cube of a number */
  93.  
  94. int Cube(int value)
  95.  
  96. {
  97. return value*value*value;
  98.  
  99. }
  100.  
  101. /* function returning half of a number */
  102.  
  103. double Shrink (int value)
  104.  
  105. {
  106. return value/2;
  107. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
3
1
4
3
-1
compilation info
prog.c: In function ‘main’:
prog.c:30:65: warning: backslash and newline separated by space
      printf ("Enter 1 to calculate Square, 2 to calculate Cube, \
                                                                  
prog.c:66:32: warning: format ‘%lf’ expects argument of type ‘double’, but argument 3 has type ‘int’ [-Wformat=]
       printf ("Cube of %d is %lf \n", intValue,Results);
                                ^
prog.c: At top level:
prog.c:103:8: error: conflicting types for ‘Shrink’
 double Shrink (int value)
        ^~~~~~
prog.c:5:8: note: previous declaration of ‘Shrink’ was here
 double Shrink (double value);
        ^~~~~~
stdout
Standard output is empty