I am having some compiling problems.

Mar 19, 2013 at 5:38am
I have this program:

#include<iostream>

#include<math.h>

using namespace std;

float a,b,c;

int istriangle()

{

if(a<(b+c)&&b<(c+a)&&c<(a+b))

return 1;

else return 0;

} void area_peri()

{

float peri,area,hperi;

peri=(a+b+c);

hperi=peri/2.0;

area= hperi*(hperi-a)*(hperi-b)*(hperi-c)*1.0;

area=sqrt(area);

cout<<"[ "<<a<<","<<b<<","<<c<<" ] has an area of "<<area<<" and perimeter of "<<peri<<endl;

return; }




void classify()

{

int r=0,s=0,i=0,e=0;

if(a*a==b*b+c*c||b*b==c*c+a*a||c*c==a*a+b*b)

r=1;

if(a==b&&b==c){

e=1;i=1;

}

else if(a==b||b==c||c==a)

{i=1;}

else s=1;

cout<<"The Classification of triangle [ "<<a<<","<<b<<","<<c<<" ] is \n"; cout<<"Right : ";

if(r==1)cout<<"Yes" << endl;else cout<<"No" <<endl;

cout<<"Isosceles :";if(i==1)cout<<"Yes" endl;

else cout<<"No" <<endl;

cout<<"Equilateral :";

if(e==1)cout<<"Yes" <<endl;

else cout<<"No" <<endl; cout<<"Scalene :";if(s==1)cout<<"Yes" <<endl;

else cout<<"No" <<endl; }




int main()

{

int flag=0;

char check;

while(1)

{ cout<<"TRIANGLE PROGRAM MENU\n";

cout<<"Compute Area and Perimeter...............A" <<endl;

cout<<"Classify.................................B" <<endl;

cout<<"Quit.....................................Q" <<endl;

cout<<"Select an Option : ";

cin>>check;

switch(check)

{ case 'A': cout<<"Enter a Triple :";

cin>>a>>b>>c; area_peri();

if(istriangle()){classify();}

else

cout<<"[ "<<a<<","<<b<<","<<c<<" ] doesnot satisfy triangle inequality" <<endl;

break;

case 'B':

cout<<"Enter a Triple :"; cin>>a>>b>>c;

if(istriangle()){classify();

} else cout<<"[ "<<a<<","<<b<<","<<c<<" ] doesnot satisfy triangle inequality" <<endl;

break;

case 'Q':

cout<<"GoodBye!\n"; flag=1;

}

if(flag==1)

break;

}

return 0;

}

I am having these issues with the compiling:

prog.cpp: In function ‘void classify()’:
prog.cpp:66:41: error: expected ‘;’ before ‘endl’

Can someone please put some fresh eyes on this program to see what the issue is?


Thank you!!
Mar 19, 2013 at 5:59am
We can help, but first help us by putting the code in the code tag. Simply use <>. Thank you :)
Mar 19, 2013 at 6:08am
Ok! Is a small error. In your void classify() function, at if(i==1) cout<<"Yes"<< endl;. You missed out the "<<".
Topic archived. No new replies allowed.