fork download
  1.  
  2.  
  3. // C code
  4. // This program will provide options for a user to calculate the square
  5. // or cube of a positive Integer input by a user.
  6. // Developer: Faculty CMIS102
  7. // Date: Jan 31, XXXX
  8. #include <stdio.h>
  9. int main ()
  10. {
  11. /* variable definition: */
  12. int intValue, menuSelect,Results;
  13. intValue = 1;
  14. // While a positive number
  15. while (intValue > 0)
  16. {
  17. printf ("Enter a positive Integer\n: ");
  18. scanf("%d", &intValue);
  19. if (intValue > 0)
  20. {
  21. printf ("Enter 1 to calculate Square, 2 to Calculate Cube \n: ");
  22. scanf("%d", &menuSelect);
  23. if (menuSelect == 1)
  24. {
  25. // Call the Square Function
  26.  
  27. Results = Square(intValue);
  28. printf("Square of %d is %o\n",intValue,Results);
  29. }
  30. else if (menuSelect == 2)
  31. {
  32. // Call the Cube function
  33. Results = Cube(intValue);
  34. printf("Cube of %d is %d\n",intValue,Results);
  35. }
  36. else
  37. printf("Invalid menu item, only 1 or 2 is accepted\n");
  38. }
  39. }
  40. return 0;
  41. }
  42. /* function returning the Square of a number */
  43. int Square(int value)
  44. {
  45. return value*value;
  46. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
16
1
-1
compilation info
prog.c: In function 'main':
prog.c:27:19: warning: implicit declaration of function 'Square' [-Wimplicit-function-declaration]
         Results = Square(intValue); 
                   ^
prog.c:33:19: warning: implicit declaration of function 'Cube' [-Wimplicit-function-declaration]
         Results = Cube(intValue); 
                   ^
/home/TheZSF/ccH8VYfc.o: In function `main':
prog.c:(.text.startup+0xa1): undefined reference to `Cube'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty