fork download
  1. #include <stdio.h>
  2. int main()
  3. {
  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 Interger\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. printfThis is hard();
  22. }
  23. else if (menuSelect == 2)
  24. {
  25. // Call the Cube funtion
  26. Results = Cube(intValue);
  27. printf("cube of %d is %d\n",intValue, Results);
  28. printfThis is hard();
  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. {
  44. return value*value*value;
  45. }
  46. void printfThis is hard(){
  47. printf("This is hard! \n");
  48. return;
  49. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
16
2
25
1
-33
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:21:1: error: unknown type name ‘printfThis’
 printfThis is hard();
 ^~~~~~~~~~
prog.c:21:15: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘hard’
 printfThis is hard();
               ^~~~
prog.c:26:11: warning: implicit declaration of function ‘Cube’ [-Wimplicit-function-declaration]
 Results = Cube(intValue);
           ^~~~
prog.c:28:1: error: unknown type name ‘printfThis’
 printfThis is hard();
 ^~~~~~~~~~
prog.c:28:15: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘hard’
 printfThis is hard();
               ^~~~
prog.c: At top level:
prog.c:46:17: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘is’
 void printfThis is hard(){
                 ^~
prog.c:46:17: error: unknown type name ‘is’
stdout
Standard output is empty