#include<graphics.h>
#include<conio.h>
 
int main()
{
   int gd = DETECT, gm;
   int x1=50,y1=50,x2=200,y2=100;
   initgraph(&gd, &gm, "C:\\TC\\BGI");
   setcolor(9);
   line(x1,y1,x2,y2);
 
   getch();
   closegraph();
   return 0;
}

here's my code in drawing a simple line in C . but it has errors it said that "undefined symbol _closegraph in module LINE.cpp (LINE is the name of the program)
symbol _line in module LINE.cpp
symbol _setcolor in module LINE.cpp

*i cant figure out what's wrong with my code , pls help tnx :D

On the assumption that you're using Turbo C, please make sure that your linker settings include the graphics library.

oh ! i forgot about that , tnx :D but i have some questions again if you dont mind . how am i supposed to create a cartesian plane in C ?

how am i supposed to create a cartesian plane in C ?

The pixel canvas is already a Cartesian plane, specifically the positive quadrant. What exactly are you trying to accomplish?

I will plot the points on the cartesian plane determine if it is straight line then if it is a straight line then i will draw the line .. can you give me some idea about this ? tnx

can you give me some idea about this ?

Figure out how you would do it on paper, then pretend you're explaining the steps to the dumbest person on the planet. That's your algorithm. Now turn those steps into code.

how am i supposed to draw a big perpendicular line ? is it possible to draw a perpendicular line ?

how am i supposed to draw a big perpendicular line ?

Perpendicular to what?

is it possible to draw a perpendicular line ?

Drawing a perpendicular line is no different than drawing a simple line like you have drawn above.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.