I am a struggling toyer with C and I've worked my way up to enumeration types and typedef and now I'm stuck. here is my code:
#include<stdio.h>
enum month{jan=1, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec};
typedef enum month month;
int main()
{
month d,m,x;
system("cls");
printf("Enter number of the month: ");
scanf("%d", &d);
printf("Current\t\tPrevious\n\n");
m=find_prev_month(d);
printf("\t\t%c\n",m);
return 0;
}
month find_prev_month(month d)
{
char x;
month prev_month;
if(d == 1)
x = "January";
switch (d)
{
case jan:
printf("%c\t\tDecember", x);
break;
case feb:
printf("\t\tJanuary");
break;
case mar:
printf("\t\tFebruary");
break;
case apr:
printf("\t\tMarch");
break;
case may:
printf("\t\tApril");
break;
case jun:
printf("\t\tMay");
break;
case jul:
printf("\t\tJune");
break;
case aug:
printf("\t\tJuly");
break;
case sep:
printf("\t\tAugust");
break;
case oct:
printf("\t\tSeptember");
break;
case nov:
printf("\t\tOctober");
break;
case dec:
printf("\t\tNovember");
break;
}
return prev_month;
}
and here is my output:
Enter number of the month: 1
Current Previous
- December
What I would like for it to do is to ask for the number of the month, then take that data, print a table of the current month that was selected and the previous month, then under that, the rest of the months in order, something along these lines if say 7 for July was entered:
Current Previous
July June
August July
September August
and so on for all 12 months. I am by no means a professional programmer, just trying to learn to better myself. HELPPPPP!!!! Thanking you all in advance.....