How get output for computer graphics lab program | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How get output for computer graphics lab program

#include <stdio.h> #include <stdlib.h> #include<graphics.h> #include<conio.h> void draw3d(int fs,int x[20],int y[20],int tx,int ty,int d); void draw3d(int fs,int x[20],int y[20],int tx,int ty,int d) { int i,j,k=0; for(j=0;j<2;j++) { for(i=0;i<fs;i++) { if(i!=fs-1) line(x[i]+tx+k,y[i]+ty-k,x[i+1]+tx+k,y[i+1]+ty-k); else line(x[i]+tx+k,y[i]+ty-k,x[0]+tx+k,y[0]+ty-k); } k=d; } for(i=0;i<fs;i++) { line(x[i]+tx,y[i]+ty,x[i]+tx+d,y[i]+ty-d); } } void main() { int gd=DETECT,gm; int x[20],y[20],tx=0,ty=0,i,fs,d; initgraph(&gd,&gm,""); printf("No of sides (front view only) : "); scanf("%d",&fs); printf("Co-ordinates : "); for(i=0;i<fs;i++) { printf("(x%d,y%d)",i,i); scanf("%d%d",&x[i],&y[i]); } printf("Depth :"); scanf("%d",&d); draw3d(fs,x,y,tx,ty,d); getch();//front view setcolor(14); for(i=0;i<fs;i++) { if(i!=fs-1) line(x[i]+200,y[i],x[i+1]+200,y[i+1]); else line(x[i]+200,y[i],x[0]+200,y[0]); } getch();//top view for(i=0;i<fs-1;i++) { line(x[i],300,x[i+1],300);

5th Dec 2020, 5:53 AM
Chandramohan
Chandramohan - avatar
2 Answers
+ 7
Hii Chandramohan It would be great if you can put the code given in description in a "code" so that it would be more understable! And can you please explain what you are exactly wiling for?
5th Dec 2020, 6:16 AM
Piyush
Piyush - avatar
+ 1
You can't use the graphics.h header file in sololearn .In codeblocks it is not a build in library.As it is not a build in library ,you have to download it. Here is the description how to download it: https://www.geeksforgeeks.org/include-graphics-h-codeblocks/ I better suggest you not to download from this website: http://winbgim.codecutter.org/ because I already downloaded it from there and it didn't work . Here is a video for you to download it: https://www.youtube.com/watch?v=eP44vFIWYws It works fine for me.
5th Dec 2020, 6:46 AM
The future is now thanks to science
The future is now thanks to science - avatar