my code not working

I hv code C++ but not working

my code

#include<iostream.h>
#include<graphics.h>

void grs_vertikal(int x1,int y1,int x2,int y2);
void grs_horisontal(int x1,int y1,int x2,int y2);
void grs_diagonal(int x1,int y1,int x2,int y2);

main ()
{
int vx1,vx2, vy1,vy2, vxy;
cout<< "PROGRAM MENGGAMBAR GARIS"endl << ;

cout<< "1. Garis vertikal" endl << ;
cout<< "2. Garis horisontal" endl << ;
cout<< "3. Garis diagonal" endl<< ;
cout<< endl<< "Pilih no. =";
cin>> vxy ;
switch(vxy)
{
case 1:
cout <<endl<<"masukkan variabel x1
=";
cin vx1;
cout <<endl<<"masukkan variabel x2
=";
cin vx2;
cout <<endl<<"masukkan variabel y1
=";
cin vy1;
cout <<endl<<"masukkan variabel y2
=";
cin vy2;

initwindow(1000,500);
grs_vertikal(10,10,50,50);
while (!kbhit());
closegraph();
}
void grs_vertikal(int x1,int y1,int x2,int y2)
{
int i,color;
color=255;
if(x1<x2)
{
for(i=x1;i<x2;i++)
{
putpixel(x1,i,color);
}
}
else
{
for(i=x1;i>x2;i++)
{
putpixel(y1,i,color);
}
}
}
break;

case 2:
cout <<endl<<"masukkan variabel x1
=";
cin vx1;
cout <<endl<<"masukkan variabel x2
=";
cin vx2;
cout <<endl<<"masukkan variabel y1
=";
cin vy1;
cout <<endl<<"masukkan variabel y2
=";
cin vy2;
initwindow(1000,500);
grs_horisontal(10,10,50,50);
while (!kbhit());
closegraph();
}
void grs_horisontal(int x1,int y1,int x2,int y2)
{
int i,color;
color=255;
if(x1<x2)
{
for(i=x1;i<=x2;i++)
{
putpixel(i,x1,color);
}
}
else
{
for(i=x1;i>=x2;i++)
{
putpixel(i,y1,color);
}
}
}

break;
case 3:
cout<< endl<< "masukkan variabel x1=";
cin>>vx1;
cout<< endl<< "masukkan variabel x2=";
cin>>vx2;
cout<< endl<< "masukkan variabel y1=";
cin>>vy1;
cout<< endl<< "masukkan variabel x1=";
cin>>vy2;
initwindow(1000,500);
grs_diagonal(10,10,50,50);
while (!kbhit());
closegraph();
}
void grs_diagonal(int x1,int y1,int x2,int y2)
{
int i,color;
color=255;
if(x1<x2)
{
for(i=x1;i<x2;i++)
{
x1++;
x2++;

putpixel(x1,i,color);

}
}
else
{
for(i=x1;i>x2;i++)
{
else
{
for(i=x1;i>=x2;i++)
{
x1++;
y1++;

{

putpixel(y1,i,color);
}
}
}

break;

getch();
}

can you help me whats wrong my code
1) Please use code tags when posting code here.
2) What do you mean, "It's not working"? We're not telepaths. TELL US WHAT THE PROBLEM IS.
3) Why are you spamming multiple forums with the same post?
Last edited on
Topic archived. No new replies allowed.