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