Hi,
I need to write a program to display the months of the year as well as creating a function to display the previous month. If the user inputs FEB than it should display JAN. I tried running the program to display the months of the year but in the for loop, I have month++ and the compiler is complaining. Is there a way you get around that?
#include <iostream>
#include <stdio.h>
enum months { JAN = 1, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP,
OCT, NEV, DEC };
int main ()
{
enum months month;
const char *monthName[] = { "", "January", "February", "March", "April",
"May", "June", "July", "August", "September",
"October", "November", "December" };
printf("Please enter
for ( month = JAN; month <= DEC; (++ month))
printf( "%2d%11s\n", month, monthName [ month ] );
return 0;
}
Start Free Trial