#include<iostream>
using namespace std;
int main()
{
Start:
int n,m;
cout<<"Zodiac Sign[1]"<<endl;
cout<<"Exit[2]"<<endl;
cin>>n;
do{
switch(n)
{
case 1:
int m,d;
cout<<"Please enter your birthday in numerical form:"<<endl;
cin>>m>>d;
if(m==3 && d>=21)
cout<<"Your zodiac sign is ARIES!"<<endl;
else if (m==4 && d<=19)
cout<<"Your zodiac sign is ARIES!"<<endl;
else if(m==4 && d>=20)
cout<<"Your zodiac sign is TAURUS!"<<endl;
else if(m==5 && d<=20)
cout<<"Your zodiac sign is TAURUS!"<<endl;
else if(m==5 && d>=21)
cout<<"Your zodiac sign is GEMINI!"<<endl;
else if(m==6 && d<=20)
cout<<"Your zodiac sign is GEMINI!"<<endl;
else if(m==6 && d>=21)
cout<<"Your zodiac sign in CANCER!"<<endl;
else if(m==7 && d<=22)
cout<<"Your zodiac sign in CANCER!"<<endl;
else if(m==7 && d>=23)
cout<<"Your zodiac sign is LEO!"<<endl;
else if(m==8 && d<=22)
cout<<"Your zodiac sign is LEO!"<<endl;
else if(m==8 && d>=23)
cout<<"Your zodiac sign is VIRGO!"<<endl;
else if(m==9 && d<=22)
cout<<"Your zodiac sign is VIRGO!"<<endl;
else if(m==9 && d>=23)
cout<<"Your zodiac sign is LIBRA!"<<endl;
else if(m==10 && d<=22)
cout<<"Your zodiac sign is LIBRA!"<<endl;
else if(m==10 && d>=23)
cout<<"Your zodiac sign is SCORPIO!"<<endl;
else if(m==11 && d<=21)
cout<<"Your zodiac sign is SCORPIO!"<<endl;
else if(m==11 && d>=22)
cout<<"Your zodiac sign is SAGITTARIUS!"<<endl;
else if(m==12 && d<=21)
cout<<"Your zodiac sign is SAGITTARIUS!"<<endl;
else if(m==12 && d>=22)
cout<<"Your zodiac sign is CAPRICORN!"<<endl;
else if(m==1 && d<=19)
cout<<"Your zodiac sign is CAPRICORN!"<<endl;
else if(m==1 && d>=20)
cout<<"Your zodiac sign is AQUARIUS!"<<endl;
else if(m==2 && d<=18)
cout<<"Your zodiac sign is AQUARIUS!"<<endl;
else if(m==2 && d>=19)
cout<<"Your zodiac sign is PISCES!"<<endl;
else if(m==3 && d<=20)
cout<<"Your zodiac sign is PISCES!"<<endl;
else;
break;
default:
cout<<"invalid output"<<endl;
break;
cout<<"Do you want to continue?[Y/N]"<<endl;
break;
}
}while(m<13);
It looks like after taking in m and d as input, on line 17 you have an extra { which prevents it from compiling. After removing it, it compiles and runs just fine for me in DevC++. In the future you might want to start using indenting for nested statements to help troubleshoot and identify extra symbols. Good luck!
#include<iostream>
usingnamespace std;
int main()
{
Start:
int n,m;
cout<<"Zodiac Sign[1]"<<endl;
cout<<"Exit[2]"<<endl;
cin>>n;
do{
if(n==1){
int m,d;
cout<<"Please enter your birthday in numerical form:"<<endl;
cin>>m>>d;
if(m==3 && d>=21)
cout<<"Your zodiac sign is ARIES!"<<endl;
elseif ((m==4) && (d<=19))
cout<<"Your zodiac sign is ARIES!"<<endl;
elseif(m==4 && d>=20)
cout<<"Your zodiac sign is TAURUS!"<<endl;
elseif(m==5 && d<=20)
cout<<"Your zodiac sign is TAURUS!"<<endl;
elseif(m==5 && d>=21)
cout<<"Your zodiac sign is GEMINI!"<<endl;
elseif(m==6 && d<=20)
cout<<"Your zodiac sign is GEMINI!"<<endl;
elseif(m==6 && d>=21)
cout<<"Your zodiac sign in CANCER!"<<endl;
elseif(m==7 && d<=22)
cout<<"Your zodiac sign in CANCER!"<<endl;
elseif(m==7 && d>=23)
cout<<"Your zodiac sign is LEO!"<<endl;
elseif(m==8 && d<=22)
cout<<"Your zodiac sign is LEO!"<<endl;
elseif(m==8 && d>=23)
cout<<"Your zodiac sign is VIRGO!"<<endl;
elseif(m==9 && d<=22)
cout<<"Your zodiac sign is VIRGO!"<<endl;
elseif(m==9 && d>=23)
cout<<"Your zodiac sign is LIBRA!"<<endl;
elseif(m==10 && d<=22)
cout<<"Your zodiac sign is LIBRA!"<<endl;
elseif(m==10 && d>=23)
cout<<"Your zodiac sign is SCORPIO!"<<endl;
elseif(m==11 && d<=21)
cout<<"Your zodiac sign is SCORPIO!"<<endl;
elseif(m==11 && d>=22)
cout<<"Your zodiac sign is SAGITTARIUS!"<<endl;
elseif(m==12 && d<=21)
cout<<"Your zodiac sign is SAGITTARIUS!"<<endl;
elseif(m==12 && d>=22)
cout<<"Your zodiac sign is CAPRICORN!"<<endl;
elseif(m==1 && d<=19)
cout<<"Your zodiac sign is CAPRICORN!"<<endl;
elseif(m==1 && d>=20)
cout<<"Your zodiac sign is AQUARIUS!"<<endl;
elseif(m==2 && d<=18)
cout<<"Your zodiac sign is AQUARIUS!"<<endl;
elseif(m==2 && d>=19)
cout<<"Your zodiac sign is PISCES!"<<endl;
elseif(m==3 && d<=20)
cout<<"Your zodiac sign is PISCES!"<<endl;
else;
break;
cout<<"invalid output"<<endl;
break;
}
cout<<"Do you want to continue?[Y/N]"<<endl;
break;
}while(m<13);
return 0;
}
Now it works fine. I modified the switch structure with a if structure. You're using the switch structure to test 2 cases? I don't think it gaves you some eficiency. You may use switch for all another cases where you use else if (is just an advice if you want).