// days in a given month.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
using namespace std;


int _tmain(int argc, _TCHAR* argv[])
{
char month,january,feburary,march,april,may,june,july,august,september,october,novemb
er,december;
cout<< "\nEnter january,feburary,march,april,may,june,july,august,september,october,november,dec
ember : ";
cin>>month;
switch(month)
{
case january:
cout<< "31\n";
break;
case feburary:
cout<< "28\n";
break;
case march:
cout<< "31\n";
break;
case april:
cout<< "30\n";
break;
case may:
cout<< "31\n";
break;
case june:
cout<< "30\n";
break;
case july:
cout<< "31\n";
break;
case august:
cout<< "31\n";
break;
case september:
cout<< "30\n";
break;
case october:
cout<< "31\n";
break;
case november:
cout<< "30\n";
break;
case december:
cout<< "31\n";
break;
}

return 0;
}
this is wht i attempted lastly...
i have display the respective months with days using switch statement

1. Next time use code tag:
[code=c++] source

[/code]

2. Alas, you forgot (;)) that case labels are constant expressions of integral (for example, an integer 123 or a single char 'x') or enumeration type. You can't type enumeration constants directly because no overloaded >> operator for enumerations.

Input text string then select month name by if statement cascade:

string month;
...
cin >> month;
int days;
if (month == "january")
    days = 31;
else if (month == "february") {
    // How about leap years?
    ...
} else if (....)
...
else { // Bad month name

}
...

3. Place system header include diectives in stdafx.h compiler generated files:

/// stdafx.h
...
#include <iostream>
#include <string>
...

Don't include them in your .cpp files. That's why you have #include "stdafx.h" VC++ compiler generated directive.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.