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

compilation info
prog.c: In function 'main':
prog.c:19:11: warning: implicit declaration of function 'Square' [-Wimplicit-function-declaration]
 Results = Square(intValue);
           ^
prog.c:25:11: warning: implicit declaration of function 'Cube' [-Wimplicit-function-declaration]
 Results = Cube(intValue);
           ^
prog.c: At top level:
prog.c:47:2: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'return'
  return 0;
  ^
prog.c:48:1: error: expected identifier or '(' before '}' token
 }
 ^
stdout
Standard output is empty