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 (intValue > 0)
  12. {
  13. printf ("Enter a positive Integer\n: ");
  14. scanf("%d", &intValue);
  15. if (intValue > 0)
  16. {
  17. printf ("Enter 1 to calculate Square, 2 to Calculate Cube \n: ");
  18. scanf("%d", &menuSelect);
  19. if (menuSelect == 1)
  20. {
  21. // Call the Square Function
  22. Results = Square(intValue);
  23. printf("Square of %d is %d\n",intValue,Results);
  24. }
  25. else if (menuSelect == 2)
  26. {
  27. // Call the Cube function
  28. Results = Cube(intValue);
  29. printf("Cube of %d is %d\n",intValue,Results);
  30. }
  31. else
  32. printf("Invalid menu item, only 1 or 2 is accepted\n");
  33. }
  34. /* function returning the Square of a number */
  35. int Square(int value)
  36. {
  37. return value*value;
  38. }
  39. /* function returning the Cube of a number */
  40. int Cube(int value)
  41. {
  42. return value*value*value;
  43. }
  44. }
  45. return 0;
  46. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
4
1
compilation info
prog.c:40:5: warning: ‘Cube’ defined but not used [-Wunused-function]
 int Cube(int value)
     ^~~~
prog.c:35:5: warning: ‘Square’ defined but not used [-Wunused-function]
 int Square(int value)
     ^~~~~~
/home/xPoAzO/ccSNvyni.o: In function `main':
prog.c:(.text.startup+0xa0): undefined reference to `Cube'
prog.c:(.text.startup+0xbf): undefined reference to `Square'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty