fork download
  1. define NUMMONTHS 12
  2. #define NUMYEARS 5
  3. #include <stdio.h>
  4.  
  5. // function prototypes
  6. void inputdata();
  7. void printdata();
  8.  
  9. // Global variables
  10. // These are available to all functions
  11. float Raindata[NUMYEARS][NUMMONTHS];
  12. float Windspeed[NUMYEARS][NUMMONTHS];
  13. char years[NUMYEARS][5] = {"2011","2012","2013","2014","2015"};
  14. char months[NUMMONTHS][12] ={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
  15. int main ()
  16. {
  17. char enterData = 'y';
  18. printf("Do you want to input Precipatation data? (y for yes)\n");
  19. scanf("%c",&enterData);
  20. if (enterData == 'y') {
  21. // Call Function to Input data
  22. inputdata();
  23.  
  24. // Call Function to display data
  25. printdata();
  26. }
  27. else {
  28. printf("No data was input at this time\n");
  29. }
  30. printf("Please try the Precipitation program again. \n");
  31. return 0;
  32. }
  33. // function to inputdata
  34. void inputdata() {
  35. /* variable definition: */
  36. float Rain=1.0;
  37. float WSP=1.0;
  38. // Input Data
  39. for (int year=0;year < NUMYEARS; year++) {
  40. for (int month=0; month< NUMMONTHS; month++) {
  41. printf("Enter rain and windspeed for %d, %d:\n", year+1, month+1);
  42. scanf("%f",&Rain);
  43. Raindata[year][month]=Rain;
  44. printf("Enter windspeed for %d, %d:\n", year+1, month+1);
  45. scanf("%f",&WSP);
  46. Windspeed[year][month]=WSP;
  47. }
  48. }
  49. }
  50. // Function to printdata
  51. void printdata(){
  52. // Print data
  53. printf ("year\t month\t rain\t wind\n");
  54. for (int year=0;year < NUMYEARS; year++) {
  55. for (int month=0; month< NUMMONTHS; month++) {
  56. printf("%s\t %s\t %5.2f %5.2f\n", years[year],months[month],Raindata[year][month],Windspeed[year][month]);
  57. }
  58. }
  59. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:1:1: error: unknown type name ‘define’
 define NUMMONTHS 12
 ^~~~~~
prog.c:1:18: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before numeric constant
 define NUMMONTHS 12
                  ^~
In file included from /usr/include/stdio.h:74:0,
                 from prog.c:3:
/usr/include/libio.h:302:3: error: unknown type name ‘size_t’
   size_t __pad5;
   ^~~~~~
/usr/include/libio.h:305:67: error: ‘size_t’ undeclared here (not in a function)
   char _unused2[15 * sizeof (int) - 4 * sizeof (void *) - sizeof (size_t)];
                                                                   ^~~~~~
/usr/include/libio.h:333:62: error: expected declaration specifiers or ‘...’ before ‘size_t’
 typedef __ssize_t __io_read_fn (void *__cookie, char *__buf, size_t __nbytes);
                                                              ^~~~~~
/usr/include/libio.h:342:6: error: expected declaration specifiers or ‘...’ before ‘size_t’
      size_t __n);
      ^~~~~~
/usr/include/libio.h:464:19: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘_IO_sgetn’
 extern _IO_size_t _IO_sgetn (_IO_FILE *, void *, _IO_size_t);
                   ^~~~~~~~~
In file included from prog.c:3:0:
/usr/include/stdio.h:339:20: error: expected declaration specifiers or ‘...’ before ‘size_t’
       int __modes, size_t __n) __THROW;
                    ^~~~~~
/usr/include/stdio.h:388:44: error: expected declaration specifiers or ‘...’ before ‘size_t’
 extern int snprintf (char *__restrict __s, size_t __maxlen,
                                            ^~~~~~
/usr/include/stdio.h:392:45: error: expected declaration specifiers or ‘...’ before ‘size_t’
 extern int vsnprintf (char *__restrict __s, size_t __maxlen,
                                             ^~~~~~
/usr/include/stdio.h:711:15: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘fread’
 extern size_t fread (void *__restrict __ptr, size_t __size,
               ^~~~~
/usr/include/stdio.h:717:15: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘fwrite’
 extern size_t fwrite (const void *__restrict __ptr, size_t __size,
               ^~~~~~
prog.c:11:26: error: ‘NUMMONTHS’ undeclared here (not in a function)
 float Raindata[NUMYEARS][NUMMONTHS];
                          ^~~~~~~~~
stdout
Standard output is empty