fork download
  1. #include <stdio.h>
  2. // Function prototypes
  3. int Square(int value);
  4. int Cube(int value);
  5. int main ()
  6. {
  7. /* variable definition: */
  8. int intValue, menuSelect,Results;
  9. intValue = 1;
  10. // While a positive number
  11. while ()
  12. {
  13. printf ("Enter a positive Integer\n: ");
  14. scanf("%d", &intValue);
  15. if ()
  16. {
  17. printf ("Enter 1 to calculate Square, 2 to Calculate Cube \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
  33. printf("Invalid menu item, only 1 or 2 is accepted\n");
  34. }
  35. }
  36. return 0;
  37. }
  38. /* function returning the Square of a number */
  39. int Square(int value)
  40. {
  41. return value*value;
  42. }
  43. /* function returning the Cube of a number */
  44. int Cube(int value)
  45. {
  46. return value*value*value;
  47. }
  48.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
10
1
10
2
-99
compilation info
prog.c: In function ‘main’:
prog.c:11:8: error: expected expression before ‘)’ token
 while ()
        ^
prog.c:15:6: error: expected expression before ‘)’ token
  if ()
      ^
stdout
Standard output is empty