Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Can you draw line in turbo c++? If so, can you send me some example code. I tried this code- error initgraph

+9 votes
asked Jan 25 by Jeff Clay (280 points)
/**********************************************
 Statement - Drawing Line in Graphics Mode
 Programmer - Vineet Choudhary
 Written For - http://developerinsider.co
 **********************************************/

#include<graphics.h>
#include<stdio.h>
#include<conio.h>

void main(void) {
    int gdriver = DETECT, gmode;
    int x1 = 200, y1 = 200;
    int x2 = 300, y2 = 300;
    clrscr();
    
    initgraph(&gdriver, &gmode, "c:\\turboc3\\bgi");
    line(x1, y1, x2, y2);
    closegraph();
    getch();
}

/*
 
Explanation of Code :
1. int x1=200, y1=200;
   int x2=300, y2=300;
   We have declared above variables so that we can keep track of starting and ending point.
 
2. line(x1,y1,x2,y2);
   We need to pass just 4 parameters to the line() function.
 
3. Line Function Draws Line From (x1,y1) to (x2,y2) .
    Syntax : line(x1,y1,x2,y2);
    ->Parameter	Explanation
        x1	X Co-ordinate of First Point
        y1	Y Co-ordinate of First Point
        x2	X Co-ordinate of Second Point
        y2	Y Co-ordinate of Second Point
*/

3 Answers

0 votes
answered Jan 27 by Peter Minarik (86,240 points)
edited Feb 20 by Peter Minarik
OnlineGDB runs on a Linux server and forwards the standard output to you.

Hence, you will not be able to perform any graphics (apart from character graphics) as video output is not the same as standard output.

That being said, you should be all good if you're running your code in your own compiler on your local machine and not using an online compiler. But I think this is not what you asked.
–1 vote
answered Feb 19 by swarna098765 (170 points)
Yes for my confestation
–1 vote
answered Feb 19 by swarna098765 (170 points)
Yes for my confirmation of
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...