fork download
  1. // C code
  2. // This program will provide options for a user to enter days reminding to give or get gifts
  3. // Developer: Darryl Ennels
  4. // Date: Nov 29, 2015
  5. #include <stdio.h>
  6. int main ()
  7. {
  8. /* variable definition: */
  9.  
  10. float intcount, intdays, menuSelect,Results, intgivinggetting;
  11. float doMath;
  12. intcount = 1;
  13. doMath = 2.22;
  14. // While a positive number
  15. while (intcount > 0)
  16. {
  17. printf ("Enter the number of days left until gifts are given\n");
  18. scanf("%f", &intdays);
  19. printf ("Enter 1 if you're giving gifts or 2 if you're getting gifts\n");
  20. scanf("%f", &intgivinggetting);
  21.  
  22. if (intcount > 0)
  23. {
  24. printf ("Enter 1 to calculate gifts to give or 2 to see how many you're getting\n\n");
  25. scanf("%f", &menuSelect);
  26. if (menuSelect == 1)
  27. {
  28. // Call the Square Function
  29. Results = give(intdays);
  30. printf("You entered %f days reminding you should give %f gifts and be Happy\n\n",intdays,Results);
  31. return 0;
  32. }
  33. else if (menuSelect == 2)
  34. {
  35. // Call the Cube function
  36. Results = getting(intdays);
  37. printf("You entered %f days reminding you will get %f gifts, lucky you\n\n",intdays,Results);
  38. return 0;
  39. }
  40. else
  41. printf("Invalid menu item, only 1 (give) or 2 (getting) is accepted\n");
  42. return 0;
  43. }
  44.  
  45.  
  46. }
  47.  
  48. return 0;
  49. }
  50.  
  51. /* function returning the Square of a number */
  52. float give(float value)
  53. {
  54. //return value*doMath;
  55. }
  56.  
  57. /* function returning the Cube of a number */
  58. float getting(float value)
  59. {
  60. //return value*value*doMath;
  61. }
  62.  
  63.  
  64.  
  65.  
Compilation error #stdin compilation error #stdout 0s 2160KB
stdin
3
2
2
compilation info
prog.c: In function 'main':
prog.c:29:19: warning: implicit declaration of function 'give' [-Wimplicit-function-declaration]
         Results = give(intdays);
                   ^
prog.c:36:19: warning: implicit declaration of function 'getting' [-Wimplicit-function-declaration]
         Results = getting(intdays);
                   ^
prog.c:11:10: warning: variable 'doMath' set but not used [-Wunused-but-set-variable]
    float doMath;
          ^
prog.c: At top level:
prog.c:52:7: error: conflicting types for 'give'
 float give(float value)
       ^
prog.c:29:19: note: previous implicit declaration of 'give' was here
         Results = give(intdays);
                   ^
prog.c:58:7: error: conflicting types for 'getting'
 float getting(float value)
       ^
prog.c:36:19: note: previous implicit declaration of 'getting' was here
         Results = getting(intdays);
                   ^
prog.c: In function 'give':
prog.c:55:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
prog.c: In function 'getting':
prog.c:61:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
stdout
Standard output is empty