Advertisement

04.26.2008 at 12:18AM PDT, ID: 23355567
[x]
Attachment Details

Enum months of the year

Asked by amlegacy in C Programming Language

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
 
Loading Advertisement...
 
[+][-]04.26.2008 at 12:27AM PDT, ID: 21444806

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.26.2008 at 12:31AM PDT, ID: 21444810

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.26.2008 at 12:46AM PDT, ID: 21444829

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.26.2008 at 12:57AM PDT, ID: 21444843

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.26.2008 at 01:01AM PDT, ID: 21444849

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.26.2008 at 01:10AM PDT, ID: 21444864

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: C Programming Language
Sign Up Now!
Solution Provided By: evilrix
Participating Experts: 2
Solution Grade: A
 
 
[+][-]04.26.2008 at 01:16AM PDT, ID: 21444879

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628