C Program for Basic Graphic Operation

Program /*Computer Graphic Title: Basic Graphic Operation Use switch case to draw following 1. Circle 2. Rectangle 3. Ellipse 4. Sq...

Program

/*Computer Graphic
Title: Basic Graphic Operation
Use switch case to draw following
1. Circle
2. Rectangle
3. Ellipse
4. Square
5. Triangle
6. Line
7. Point
*/

#include<conio.h>
#include<stdio.h>
#include<graphics.h>
void main()
{
int gd=DETECT,gm,n,x1,y1,x2,y2,x3,y3,r;
initgraph(&gd,&gm,"..\\bgi");
clrscr();
a:printf("\nChoose the option below\n1. Circle\n2. Rectangle\n3. Ellipse\n4. Square\n5. Triangle\n6. Line\n7. Point\n8. Exit\nEnter Choice: ");
scanf("%d",&n);
switch(n)
{
case 1:
printf("Enter x-coordinate, y-coordinate and radius for circle.\n");
printf("x-coordinate: ");
scanf("%d",&x1);
printf("y-coordinate: ");
scanf("%d",&y1);
printf("radius: ");
scanf("%d",&r);
printf("Circle is drawn\n");
circle(x1,y1,r);
break;

case 2:
printf("Enter x1-coordinate, y1-coordinate, x2-coordinate and y2-coordinate for rectangle.\n");
printf("x1-coordinate: ");
scanf("%d",&x1);
printf("y1-coordinate: ");
scanf("%d",&y1);
printf("x2-coordinate: ");
scanf("%d",&x2);
printf("y2-coordinate: ");
scanf("%d",&y2);
printf("Rectangle is drawn\n");
rectangle(x1,y1,x2,y2);
break;

case 3:
printf("Enter x-coordinate, y-coordinate, x-axis radius and y-axis radius for ellipse.\n");
printf("x-coordinate: ");
scanf("%d",&x1);
printf("y-coordinate: ");
scanf("%d",&y1);
printf("x-axis radius: ");
scanf("%d",&x2);
printf("y-axis radius: ");
scanf("%d",&y2);
printf("Ellipse is drawn\n");
ellipse(x1,y1,0,360,x2,y2);
break;

case 4:
printf("Enter x-coordinate, y-coordinate, and length for square.\n");
printf("x-coordinate: ");
scanf("%d",&x1);
printf("y-coordinate: ");
scanf("%d",&y1);
printf("length: ");
scanf("%d",&r);
printf("Square is drawn\n");
rectangle(x1,y1,x1+r,y1+r);
break;

case 5:
printf("Enter x1-coordinate, y1-coordinate, x2-coordinate, y2-coordinate, x3-coordinate and y3-coordinate for triangle.\n");
printf("x1-coordinate: ");
scanf("%d",&x1);
printf("y1-coordinate: ");
scanf("%d",&y1);
printf("x2-coordinate: ");
scanf("%d",&x2);
printf("y2-coordinate: ");
scanf("%d",&y2);
printf("x3-coordinate: ");
scanf("%d",&x3);
printf("y3-coordinate: ");
scanf("%d",&y3);
printf("Triangle is drawn\n");
line(x1,y1,x2,y2);
line(x2,y2,x3,y3);
line(x3,y3,x1,y1);
break;

case 6:
printf("Enter x1-coordinate, y1-coordinate, x2-coordinate and y2-coordinate for line.\n");
printf("x1-coordinate: ");
scanf("%d",&x1);
printf("y1-coordinate: ");
scanf("%d",&y1);
printf("x2-coordinate: ");
scanf("%d",&x2);
printf("y2-coordinate: ");
scanf("%d",&y2);
printf("Line is drawn\n");
line(x1,y1,x2,y2);
break;
case 7:
printf("Enter x-coordinate, y-coordinate, and value of color for point.\n");
printf("x-coordinate: ");
scanf("%d",&x1);
printf("y-coordinate: ");
scanf("%d",&y1);
printf("color value: ");
scanf("%d",&x2);
printf("Point is drawn\n");
putpixel(x1,y1,x2);
break;
case 8:
exit() ;

default:
printf("Enter valid choice\n");
break;

}
goto a;
//getch();
}

Output

 






COMMENTS

BLOGGER: 1
Loading...
Name

Accident Alert,1,AI,2,Array,1,Aurdino,1,C,2,Computer Graphics,9,Data Science,3,Dataset,1,Decoratot,1,Django,1,ESP32,1,Fixed point/iteration method,1,Greater or smaller,1,html,1,Image Processing,1,JAVA,1,Javascript,22,Machine Learning,1,Matlab,3,Numerical Method,13,OOP,1,Other,3,PHP,1,Point operation,1,Python,11,Raspberry pi,1,Recommendation System,1,Regression,1,Reservation System,1,Robotics,1,Simulation,2,sine wave,1,String Handling Function,1,Web scrap,1,Webpage,1,
ltr
item
COMPUTER PROGRAMMING: C Program for Basic Graphic Operation
C Program for Basic Graphic Operation
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1p5Hc5r9ySdFwiORu1_dT20hgMTKKDFpjtNiyweVtFSNuiHGQFtGZP0j-NdnpSmhs29GP0ER06stKUu0XzcA1EiVRY0nWmfSNCVQwuDEf8zB-u8bIVBGe-za31zNkF70mcKc-JDT5VI8/s400/Screenshot+%252897%2529.png
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1p5Hc5r9ySdFwiORu1_dT20hgMTKKDFpjtNiyweVtFSNuiHGQFtGZP0j-NdnpSmhs29GP0ER06stKUu0XzcA1EiVRY0nWmfSNCVQwuDEf8zB-u8bIVBGe-za31zNkF70mcKc-JDT5VI8/s72-c/Screenshot+%252897%2529.png
COMPUTER PROGRAMMING
https://computerprogram4ru.blogspot.com/2017/10/c-program-for-basic-graphic-operation.html
https://computerprogram4ru.blogspot.com/
https://computerprogram4ru.blogspot.com/
https://computerprogram4ru.blogspot.com/2017/10/c-program-for-basic-graphic-operation.html
true
8672391763020279633
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy