fork download
  1. #include <stdio.h>
  2.  
  3. // Function prototypes int Square(int value); int Cube(int value);
  4.  
  5. int main ()
  6. {
  7. /* variable definition: */
  8. int intValue, menuSelect,Results;
  9. intValue = 1;
  10. // While a positive number
  11. while (intValue > 0)
  12. {
  13. printf ("Enter a positive Integer\n: ");
  14. scanf("%d", &intValue);
  15. if (intValue > 0)
  16. {
  17. printf ("Enter 1 to calculate Square, 2 to Calculate Cube, 3 to calculate Shrink \n: ");
  18. scanf("%d", &menuSelect);
  19.  
  20. if (menuSelect == 1)
  21. {
  22. // Call the Square Function
  23. Results = Square(intValue);
  24. printf("Square of %d is %d\n",intValue,Results);
  25. }
  26. else if (menuSelect == 2)
  27. {
  28. // Call the Cube function
  29. Results = Cube(intValue);
  30. printf("Cube of %d is %d\n",intValue,Results);
  31. }
  32. else if (menuSelect == 3)
  33. {
  34. // Call the Shrink function
  35. Results = Shrink(intValue);
  36. printf("Shrink of %d is %lf\n",intValue,Results);
  37. }
  38. else
  39. printf("Invalid menu item, only 1, 2, or 3 is accepted\n");
  40. }
  41. }
  42. return 0;
  43. }
  44. /* function returning the Square of a number */
  45. int Square(int value)
  46. {
  47. return value*value;
  48. }
  49. /* function returning the Cube of a number */
  50. int Cube(int value)
  51. {
  52. return value*value*value;
  53. }
  54. /* function returning the shrink of a number */
  55. double Shrink(int value)
  56. {
  57. return value/2;
  58. }
  59.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
10
1
3
3
-99
compilation info
prog.c: In function ‘main’:
prog.c:23:19: warning: implicit declaration of function ‘Square’ [-Wimplicit-function-declaration]
         Results = Square(intValue);
                   ^~~~~~
prog.c:29:19: warning: implicit declaration of function ‘Cube’ [-Wimplicit-function-declaration]
         Results = Cube(intValue);
                   ^~~~
prog.c:35:19: warning: implicit declaration of function ‘Shrink’ [-Wimplicit-function-declaration]
         Results = Shrink(intValue);
                   ^~~~~~
prog.c:36:35: warning: format ‘%lf’ expects argument of type ‘double’, but argument 3 has type ‘int’ [-Wformat=]
         printf("Shrink of %d is %lf\n",intValue,Results);
                                   ^
prog.c: At top level:
prog.c:55:8: error: conflicting types for ‘Shrink’
 double Shrink(int value)
        ^~~~~~
prog.c:35:19: note: previous implicit declaration of ‘Shrink’ was here
         Results = Shrink(intValue);
                   ^~~~~~
stdout
Standard output is empty