Difficulty with ending loop/while statement

Hey guys, I am not sure why the loop will not close. Any ideas??

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
#include <cstdlib>
#include <iostream>
using namespace std;

int main()
{
//define variables
 char letter = ' ';
int cfAndy = 0;
int cfBri =0;
int cfChuck=0;
char e = 'e';
	
// convert character to uppercase
letter = toupper(letter);
	
//equation
while (letter != e)
{
cout << "Enter A for Andy, B for Brianna, C for Chuck or E to exit: ";
cin >> letter;
		
if (letter='A') 
{
 cfAndy=cfAndy+1;
 }
    	
 else if (letter='B')
{			
cfBri=cfBri+1;
}
		
else if (letter='C')
{
			
cfChuck=cfChuck+1;
}
}
	
//Total votes
cout << "Number of votes for Andy: "<<cfAndy <<endl;
cout << "Number of votes for Brianna: "<<cfBri <<endl;
cout << "Number of votes for Chuck: "<<cfChuck <<endl;
	
	
//Determine ties
if (cfAndy=cfBri)
{
cout << "Andy and Brianna tied."<<endl;
}
	
else if (cfAndy=cfChuck)
{
cout << "Andy and Chuck tied."<<endl;
}
	
else 
{(cfBri=cfChuck);
		
cout << "Brianna and Chuck tied."<<endl;
}

   system("pause");
   return 0;
}
Last edited on
Your if statements are wrong.

1
2
3
if (letter='A') // == not =

if (letter == 'A') 


Do that on all of the statements.

If you input "e" It does exit.
I hate overlooking the small things... Thanks!!
Topic archived. No new replies allowed.