My do-while loop won't terminate the command why?[HELP]

#include<iostream>
using namespace std;
int main(){
{
Start:
int n,m;
char re;
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 is CANCER!"<<endl;
else if(m==7 && d<=22)
cout<<"Your zodiac sign is 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;

cout<<"invalid output"<<endl;

}
start:
cout<<"Do you want to continue?[Y/N]"<<endl;
cout<<"You must type a 'Y' or an 'N'.\n"<<endl;
cin>>re;
break;
}while(re=='Y'||re=='Y');




return 0;}
}
Woah, that's seriously messy code.
To be honest. Can we see some "pseudo"-code about how you are thinking to do this.

for example:
1. Ask user do they want to know "zodiac sign" y/n (=1/0)
2. tell the date of birth
3....


Code you posted is... well... (SORRY) POOR.
Please use [code]Code here[/code] to format you code as: Code here
1. why do you redeclare the "m" variable inside the loop?

2. I'm not familiar with the "Start:" command you use at the end, so I may be wrong by saying this but, I don't think the last "break" is necessary.

3. while (re=='Y'||re=='Y') you are comparing the same thing here. I think you mean to check for an upper case or a lower case i.e "Y || y" not "Y || Y"

4. It is not clear in your question if the program won't compile or if the loop won't terminate. If is the latter you may want to check you are using upper case when entering "Y" or even better, use "toupper"
Three people telling him how he did bad at posting, and no help .

That's the spirit !

...

As for the code, I don't know, sorry . Wish I could help ..
Sorry for that..I'm only a beginner I don't really understands what my professor said..
skylinerR390: as for as the others I don't know in
2.)I tried to run the program but without the start my loop won't appear so I tried putting start to make my loop appear.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#include<iostream>
using namespace std;
int main(){
{
Start:
int n,m;
char re;
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 is CANCER!"<<endl;
else if(m==7 && d<=22)
cout<<"Your zodiac sign is 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;

cout<<"invalid output"<<endl;

}
start:
cout<<"Do you want to continue?[Y/N]"<<endl;
cout<<"You must type a 'Y' or an 'N'.\n"<<endl;
cin>>re;
break;
}while(re=='Y'||re=='Y');




return 0;}
}


1. remove start
2. the last "invalid output" message should be put with the last "else". then only put the "break;" and close the switch statement
3. remove the "break" after the cin statement
4. and the 2 'Y' are upper case... 1 should be lowercase

hope it helps.. :)
Topic archived. No new replies allowed.