Jump to content

HELP!

- - - - -

  • Please log in to reply
2 replies to this topic

#1
daisyotso

daisyotso

    Newbie

  • Members
  • Pip
  • 4 posts
i'm a newbie in C programming. i am studying how to make a line. i have a code here and it only produces a horizontal line. can you please teach me how to make a vertical line and diagonal line using the equation:

1) dx= x2-x1
dy = y2-y1

2) slope=dx-dy




#include<iostream.h>
#include<conio.h>

void linedraw(int x1, int x2, int y1, int y2);

main ()
{
clrscr();
double x1,x2,y1,y2,dx,dy;
cout<<"enter the value of x1:";
cin>>x1;
cout<<"enter the value of y1:";
cin>>y1;
cout<<"enter the value of x2:";
cin>>x2;
cout<<"enter the value of y2:";
cin>>y2;


void linedraw (int x1, int x2, int y1, int y2);
dx= x2-x1;
dy = y2-y1;

int slope;
slope=dx-dy;

gotoxy(x1,y1);
cout<<"Û";

if(dy==0)

for(int x=x1; x<x2;x++)
{
gotoxy(x+1,y1);
cout<<"Û";
}
else if (dx==0);
for(int x=y1; x<y2;x++)
{
gotoxy(x2,x+1);
cout<<"Û";
}

getch();
return 0;



}

#2
Flying Dutchman

Flying Dutchman

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 889 posts
  • Location:::1
Drawing on terminal (cmd) can be really difficult. I'd suggest you pick a game (or math library that support drawing) to make your life easier. You will also be able to produce much more detailed curves.
A conclusion is where you got tired of thinking.
#define class struct    // All is public.

#3
daisyotso

daisyotso

    Newbie

  • Members
  • Pip
  • 4 posts
.thank you. i will try it.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users