Loop Trouble(Simple Program)

Trying to figure out why this loop decides to run an extra time no matter what.Any Help would be greatly appreciated.

#include <iostream>
#include<cctype>
using namespace std;

enum triangletype{scalene,isosceles,equilateral,notriangle};


void getsides(int&side1,int&side2,int&side3);
triangletype determineShape(int side1,int side2,int side3,triangletype&shape);
void displayShape(triangletype shape);
int main()
{
int side1,side2,side3,response;
triangletype shape;

getsides(side1,side2,side3);
shape=determineShape(side1,side2,side3,shape);
displayShape(shape);

cout<<"Do You Wish to Quit(Y or N):";
cin>>response;
response=toupper(response);

do { getsides(side1,side2,side3);
shape=determineShape(side1,side2,side3,shape);
displayShape(shape);
}
while(response =='N');


return 0;
}

void getsides(int&side1,int&side2,int&side3)
{
cout<<"Enter A Side of a Triangle: ";
cin>>side1;
cout<<"Enter The Second Side of a Triangle: ";
cin>>side2;
cout<<"Enter The Third Side of a Triangle: ";
cin>>side3;
}

triangletype determineShape(int side1,int side2,int side3,triangletype&shape)
{
if(side1+side2>side3&&side2+side3>side1&&side1+side3>side2)
{
if(side1==side2&&side2==side3&&side3==side1)
return equilateral;
else if (side1==side2||side1==side3||side2==side3)
return isosceles;
else
return scalene;
}
else
return notriangle;
}

void displayShape(triangletype shape)
{
if(shape==equilateral)
cout<<"This Triangle is Equilateral."<<endl;
else if(shape==isosceles)
cout<<"This Triangle is Isosceles."<<endl;
else if(shape==scalene)
cout<<"This Triangle is Scalene."<<endl;
else
cout<<"This Is Not A Triangle."<<endl;
}
 
do { ... } while();


always execute at least once, since the while condition is checked at the end of the loop.
but even when I go to compile it,it just spits garbage back at me.
Code tags, please.

Garbage? Could you be more descriptive? Do you mean you are getting errors or something?
it will run my program correctly then regardless of the loop it will display the void getsides cout statement then give the press any key to continue. I tried to debug and I know the error is in the loop,i cant just find out how to correct it.
You never prompt if they want to quit inside the loop, so the loop will run forever if they input 'N' the first time, once if they input anything else.
Topic archived. No new replies allowed.