fork download
  1. #include <stdio.h>
  2.  
  3. // Function prototypes
  4. int Square(int value);
  5. int Cube(int value);
  6. int main ()
  7. {
  8. /* variable definition: */
  9. int intValue, menuSelect,Results;
  10. intValue = 1;
  11. // While a positive number
  12. while (intValue > 0)
  13. {
  14. printf ("Enter a positive Integer\n: ");
  15. scanf("%d", &intValue);
  16. if (intValue > 0)
  17. {
  18. printf ("Enter 1 to calculate Square, 2 to Calculate Cube \n: ");
  19. scanf("%d", &menuSelect);
  20. 4
  21. if (menuSelect == 1)
  22. {
  23. // Call the Square Function
  24. Results = Square(intValue);
  25. printf("Square of %d is %d\n",intValue,Results);
  26. }
  27. else if (menuSelect == 2)
  28. {
  29. // Call the Cube function
  30. Results = Cube(intValue);
  31. printf("Cube of %d is %d\n",intValue,Results);
  32. }
  33. else
  34. printf("Invalid menu item, only 1 or 2 is accepted\n");
  35. }
  36. }
  37. return 0;
  38. }
  39. /* function returning the Square of a number */
  40. int Square(int value)
  41. {
  42. return value*value;
  43. }
  44. /* function returning the Cube of a number */
  45. int Cube(int value)
  46. {
  47. return value*value*value;
  48. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
10
1
10
2
-99
compilation info
prog.c: In function ‘main’:
prog.c:20:1: warning: statement with no effect [-Wunused-value]
 4
 ^
prog.c:21:1: error: expected ‘;’ before ‘if’
 if (menuSelect == 1)
 ^~
prog.c:9:26: warning: unused variable ‘Results’ [-Wunused-variable]
 int intValue, menuSelect,Results;
                          ^~~~~~~
stdout
Standard output is empty