do..while loop being ignored

Hello,this program works great except the do..while loop..I want this loop to run in the main function and make the program loop until the user decides to quit,but the loop is being ignored for whatever reason I can't seem to figure out..Thanks in advance
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
#include<iostream>

using namespace std;

//Enumerated datatype
enum typeOfTriangle {scalene,isosoceles,equilateral,noTriangle};
	
//Enumerated variable
typeOfTriangle typeTriangle;

//Function Prototypes
void getLengths(int& side1,int& side2,int& side3);
void determineShape(int side1,int side2,int side3,typeOfTriangle& typeTriangle);
void displayShape(typeOfTriangle typeTriangle);

int main()
{

do{
//variables
int side1,side2,side3;



//Function Calls
getLengths(side1,side2,side3);
determineShape(side1,side2,side3,typeTriangle);
displayShape(typeTriangle);

cout << "Do you wish to quit?(Y or N): ";	
cin >> response;
response = toupper(response);
while } (response == 'N');

system("PAUSE");
return 0;	
}

//Get Length function
void getLengths(int& side1,int& side2,int& side3)
{
	cout << "Enter side 1: ";
	cin >> side1;
	cout << "Enter side 2: ";
	cin >> side2;
	cout << "Enter side 3: ";
	cin >> side3;
}

//Determine Triangle shape function
void determineShape(int side1,int side2,int side3,typeOfTriangle& typeTriangle)
{
if (side1 + side2 < side3 || side2+side3<side1 || side1 + side3 < side2)
	typeTriangle = noTriangle;

else if (side1 == side2 && side2 == side3)
	typeTriangle = equilateral;

else if (side1 == side2 || side2 == side3 || side1 == side3)
	typeTriangle = isosoceles;
 
else if (side1 != side2 && side2 != side3) 
typeTriangle = scalene;
}

//Display shape function
void displayShape(typeOfTriangle typeTriangle)
{
	switch(typeTriangle)
	{
	case noTriangle:
		cout << "Not a valid triangle" << endl;
		break;

	case equilateral:
		cout << "equilateral" << endl;
		break;

	case scalene:
		cout << "scalene" << endl;
		break;

	case isosoceles:
		cout << "isosoceles" << endl;
		break;
		
	}

}

response == 'Y'
You should get the syntext error for this

do{
//variables
int side1,side2,side3;

//Function Calls
getLengths(side1,side2,side3);
determineShape(side1,side2,side3,typeTriangle);
displayShape(typeTriangle);

cout << "Do you wish to quit?(Y or N): ";
cin >> response;
response = toupper(response);
while } (response == 'N');

As the last line should be .
} while (response == 'N');

Also you have not declared response .. It should be declared as

char response;
Are you using Dev-C++ or MV C++? Because if you are using Dev there is a string compare function. But if your using MV you could use EOF.
here's the program however, i put in some bugs that you are able to fix.

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
#include<iostream>

using namespace std

//Enumerated datatype
enum typeOfTriangle {
scalene,isosoceles,equilateral,noTriangle
}
	
//Enumerated variable
typeOfTriangle typeTriangle;

//Function Prototypes
void getLengths(int side1,int side2,int side3);
void determineShape(int side1,int side2,int side3,typeOfTriangle typeTriangle);
void displayShape(typeOfTriangle typeTriangle);

main()
{
     int side1,side2,side3;
      char again = 'y';
      while (again != 'n' && again != 'N')
      {
             cout << "want to run the program? enter y or n\n";
             cin >> again;
             if (again == 'y')
             {
             getLengths(side1,side2,side3);
             determineShape(side1,side2,side3,typeTriangle);
             displayShape(typeTriangle);
             }
             else
             {
                 break
             }       
      }
      system("pause");
}

//Get Length function
void getLengths(int side1,int side2,int side3)
{
	cout < "\nEnter side 1: ";
	cin > side1;
	cout < "\nEnter side 2: ";
	cin > side2;
	cout << "\nEnter side 3: ";
	cin > side3;
}

//Determine Triangle shape function
void determineShape(int side1,int side2,int side3,typeOfTriangle typeTriangle)
{
     if (side1 + side2 < side3 || side2+side3<side1 || side1 + side3 < side2)
     {
	           typeTriangle ==noTriangle;
     }
     else if (side1 == side2 && side2 == side3)
     {
             typeTriangle ==equilateral;
     }
     else if (side1 == side2 || side2 == side3 || side1 == side3)
     {
	      typeTriangle ==isosoceles;
     }
     else
     { 
         typeTriangle== scalene;
     }
}

//Display shape function
void displayShape(typeOfTriangle typeTriangle)
{
	switch(typeTriangle)
	{
	case noTriangle: cout << "Not a valid triangle" << endl; break

	case equilateral: cout << "equilateral" << endl; break

	case scalene: cout << "scalene" << endl; break

	case isosoceles: cout << "isosoceles" << endl; break
		
	}
closed account (S6k9GNh0)
coolProgramer5 wrote:
Are you using Dev-C++ or MV C++? Because if you are using Dev there is a string compare function. But if your using MV you could use EOF.


This is completely wrong and makes me believe that you do not know how the C++ STL or C standard libraries and headers works.
thankyou nilesh
Topic archived. No new replies allowed.