/* This is the thirteenth lab of Lab EE107
The purpose of this lab for enumeration for months.
Creating the code and free of syntax and grammatical errors.
Author: Ekwegbalum Unachukwu
Star ID:do2170dt
Date: April 23rd, 2024.
*/
#include <stdio.h>
enum month_EU { january_EU = 1, february_EU, march_EU, april_EU, may_EU, june_EU,
july_EU, august_EU, september_EU, october_EU, november_EU, december_EU };
int main(void)
{
// Declaration of variables
enum month_EU aMonth_EU;
int days_EU;
// Prompt user to enter month number
printf("Enter month number: ");
//input foe the address passing to an integer pointer
scanf("%i", (int *)&aMonth_EU);
// Switch statement to determine days in the month
switch (aMonth_EU)
{
case january_EU: case march_EU: case may_EU: case july_EU: case august_EU:
case october_EU: case december_EU:
days_EU = 31;
break;
case april_EU: case june_EU: case september_EU: case november_EU:
days_EU = 30;
break;
case february_EU:
days_EU = 28;
break;
default:
printf("Bad month number\n");
days_EU = 0;
break;
}
// Output the number of days
if (days_EU != 0)
{
printf("Number of days is %i\n", days_EU);
if (aMonth_EU == february_EU)
printf("...or 29 if it's a leap year\n");
}
// Return 0 to indicate successful execution
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: