This isn't compiling properly. Where do I declare month_t and cur_month #include #include int main() { enum month_t {HAPPYNEWYEAR=1, /*enumeration*/ SUMMER=6,BACKTOSCHOOL=9,HAPPYHOLIDAYS=12}; month_t cur_month=BACKTOSCHOOL; switch(cur_month) { case HAPPYNEWYEAR: printf("Happy New Year\n"); break; case SUMMER: printf("Summer begins\n"); break; case BACKTOSCHOOL: printf("Back to school\n"); break; case HAPPYHOLIDAYS: printf(" Happy Holidays\n"); break; } getch(); return 0; }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

This isn't compiling properly. Where do I declare month_t and cur_month

#include <stdio.h>
#include<conio.h>
int main()
{

enum month_t {HAPPYNEWYEAR=1, /*enumeration*/
SUMMER=6,BACKTOSCHOOL=9,HAPPYHOLIDAYS=12};


month_t cur_month=BACKTOSCHOOL;

switch(cur_month)
{
case HAPPYNEWYEAR:
printf("Happy New Year\n");
break;
case SUMMER:
printf("Summer begins\n");
break;
case BACKTOSCHOOL:
printf("Back to school\n");
break;
case HAPPYHOLIDAYS:
printf(" Happy Holidays\n");
break;
}

getch();
return 0;

}

 

 

**Build Error Log Explanation**

The following is a transcription and explanation of a build error log, commonly encountered during programming and compilation tasks:

```
"C:\Program Files (x86)\quincy\mingw\bin\gcc.exe" -std=c99 -fgnu89-inline -Wno-write-strings -g3 
c:\users\ashle\documents\gray-ashley-hw2-ex1.c - In function 'main':
c:\users\ashle\documents\gray-ashley-hw2-ex1.c:11: error: 'month_i' undeclared (first use in this function)
c:\users\ashle\documents\gray-ashley-hw2-ex1.c:11: error: (Each undeclared identifier is reported only once
c:\users\ashle\documents\gray-ashley-hw2-ex1.c:11: error: for each function it appears in.)
c:\users\ashle\documents\gray-ashley-hw2-ex1.c:13: error: expected ';' before 'cur_month'
c:\users\ashle\documents\gray-ashley-hw2-ex1.c:13: error: 'cur_month' undeclared (first use in this function)
Unsuccessful build
```

**Description:**
This error log indicates multiple issues within a C programming file (`gray-ashley-hw2-ex1.c`). Here is a breakdown of the errors:

1. **Error Location**:
   - The errors are occurring within the `main` function of the `gray-ashley-hw2-ex1.c` file, particularly at lines 11 and 13.

2. **Undeclared Identifiers**:
   - **`month_i` (Line 11)**: This identifier has not been declared before it is used. This means that within the function `main`, the variable `month_i` is referenced without prior declaration.
   - **`cur_month` (Line 13)**: Similar to `month_i`, the identifier `cur_month` is also used without being declared.

3. **Syntax Error**:
   - **Missing Semicolon (Line 13)**: There is a missing semicolon expected before the identifier `cur_month`. This indicates a syntax error in the code.

4. **General Information**:
   - The error message specifies that each undeclared identifier is reported only once per
Transcribed Image Text:**Build Error Log Explanation** The following is a transcription and explanation of a build error log, commonly encountered during programming and compilation tasks: ``` "C:\Program Files (x86)\quincy\mingw\bin\gcc.exe" -std=c99 -fgnu89-inline -Wno-write-strings -g3 c:\users\ashle\documents\gray-ashley-hw2-ex1.c - In function 'main': c:\users\ashle\documents\gray-ashley-hw2-ex1.c:11: error: 'month_i' undeclared (first use in this function) c:\users\ashle\documents\gray-ashley-hw2-ex1.c:11: error: (Each undeclared identifier is reported only once c:\users\ashle\documents\gray-ashley-hw2-ex1.c:11: error: for each function it appears in.) c:\users\ashle\documents\gray-ashley-hw2-ex1.c:13: error: expected ';' before 'cur_month' c:\users\ashle\documents\gray-ashley-hw2-ex1.c:13: error: 'cur_month' undeclared (first use in this function) Unsuccessful build ``` **Description:** This error log indicates multiple issues within a C programming file (`gray-ashley-hw2-ex1.c`). Here is a breakdown of the errors: 1. **Error Location**: - The errors are occurring within the `main` function of the `gray-ashley-hw2-ex1.c` file, particularly at lines 11 and 13. 2. **Undeclared Identifiers**: - **`month_i` (Line 11)**: This identifier has not been declared before it is used. This means that within the function `main`, the variable `month_i` is referenced without prior declaration. - **`cur_month` (Line 13)**: Similar to `month_i`, the identifier `cur_month` is also used without being declared. 3. **Syntax Error**: - **Missing Semicolon (Line 13)**: There is a missing semicolon expected before the identifier `cur_month`. This indicates a syntax error in the code. 4. **General Information**: - The error message specifies that each undeclared identifier is reported only once per
Expert Solution
Working Code :

#include <stdio.h>
#include<conio.h>
int main()
{

enum month_t {HAPPYNEWYEAR=1, /*enumeration*/
SUMMER=6,BACKTOSCHOOL=9,HAPPYHOLIDAYS=12};


enum month_t cur_month=BACKTOSCHOOL;

switch(cur_month)
{
case HAPPYNEWYEAR:
printf("Happy New Year\n");
break;
case SUMMER:
printf("Summer begins\n");
break;
case BACKTOSCHOOL:
printf("Back to school\n");
break;
case HAPPYHOLIDAYS:
printf(" Happy Holidays\n");
break;
}

getch();
return 0;

}

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Data members
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education