To add to what k5054 says, do yourself a favour and properly indent your code: not only does it make an app a lot easier to read, it makes missing curly brackets a lot more obvious.
Most good editors can reformat code to your prefered indentation style, and help you indent it as you edit.
Take your
main
function for example:
int main()
{
int gd = DETECT,gm;
int x1,y1,x2,y2,thick,wy,i;
Line B;
cout<<"Enter two end pointsof line:\n";
cin>>x1>>y1;
cin>>x2,y2;
while(1)
{
cout<<"\nEnter the Style\n";
cout<<"1.Simple\n";
cout<<"2.Dash\n";
cout<<"3.Dash dot\n";
cout<<"4.Dot\n";
cout<<"5.Thick\n";
cout<<"6.Exit\n";
cout<<"Enter your style\n";
cin>>B.ch;
if(B.ch==5)
{
cout<<"Enter the thickness of line:";
cin>>thick;
}
initgraph(&gd,&gm,NULL);
xmax=getmaxx();
ymax=getmaxy();
xmid=xmax/2;
ymid=ymax/2;
if(B.ch<=4)
{
B.bss(x1,y1,x2,y2);
delay(300);
}
else
{
B.bss(x1,y1,x2,y2);
delay(300);
if((y2-y1)(x2-x1)<1)
{
wy=(thick-1)*sqrt(pow(x2-x1),2)+pow(y2-y1),2))/(2*fabs(x2-x1));
for(i=0;i<wy;i++)
{
B.bss(x1,y1-i,x2,y2-i);
delay(300);
B.bss(x1,y1+i,x2,y2+i);
delay(300);
}
}
else
wx=(thick-1)*sqrt(pow(x2-x1),2)+pow(y2-y1),2))/(2*fabs(y2-y1));
for(i=0;i<wx;i++)
{
B.bss(x1-i,y1,x2-i,y2);
delay(300);
B.bss(x1+i,y1,x2+i,y2);
delay(300);
}
}
if(B.ch==6)
{
cout<<"Exiting....";
exit(1);
}
closegraph();
}
return 0;
}
Is a lot harder to work with than this:
int main()
{
int gd = DETECT, gm;
int x1, y1, x2, y2, thick, wy, i;
Line B;
cout << "Enter two end pointsof line:\n";
cin >> x1 >> y1;
cin >> x2, y2;
while (1)
{
cout << "\nEnter the Style\n";
cout << "1.Simple\n";
cout << "2.Dash\n";
cout << "3.Dash dot\n";
cout << "4.Dot\n";
cout << "5.Thick\n";
cout << "6.Exit\n";
cout << "Enter your style\n";
cin >> B.ch;
if (B.ch == 5)
{
cout << "Enter the thickness of line:";
cin >> thick;
}
initgraph(&gd, &gm, NULL);
xmax = getmaxx();
ymax = getmaxy();
xmid = xmax / 2;
ymid = ymax / 2;
if (B.ch <= 4)
{
B.bss(x1, y1, x2, y2);
delay(300);
}
else
{
B.bss(x1, y1, x2, y2);
delay(300);
if ((y2 - y1)(x2 - x1) < 1)
{
wy = (thick-1)*sqrt(pow(x2-x1),2)+pow(y2-y1),2))/(2*fabs(x2-x1));
for (i = 0; i < wy; i++)
{
B.bss(x1, y1 - i, x2, y2 - i);
delay(300);
B.bss(x1, y1 + i, x2, y2 + i);
delay(300);
}
}
else
wx = (thick-1)*sqrt(pow(x2-x1),2)+pow(y2-y1),2))/(2*fabs(y2-y1));
for (i = 0; i < wx; i++)
{
B.bss(x1 - i, y1, x2 - i, y2);
delay(300);
B.bss(x1 + i, y1, x2 + i, y2);
delay(300);
}
}
if (B.ch == 6)
{
cout << "Exiting....";
exit(1);
}
closegraph();
}
return 0;
}