Posts

Showing posts from August, 2017

C Graphics Moving CAR Program

Image
Program : #include <stdio.h> #include <graphics.h> #include <conio.h> #include <dos.h> #include<stdlib.h> void main()  {     int gd = 0, gm;     int i=0,x,y;     /* initialize graphic mode */     initgraph(&gd, &gm, "C:\\TC\\BGI");     /* maximum pixel in horizontal axis */     x = getmaxx();     /* mid pixel in vertical axis */     y = getmaxy()/2;     while(!kbhit())     { /* draw a white road */ setcolor(WHITE); line(0, y + 37, x, y + 37); /* Draw Car */ setcolor(YELLOW); setfillstyle(SOLID_FILL, RED); line(i,y + 23, i, y); line(i, y, 40 + i, y - 20); line(40 + i, y - 20, 80 + i, y - 20); line(80 + i, y - 20, 100 + i, y); line(100 + i, y, 120 + i, y); line(120 + i, y, 120 + i, y + 23); line(0 + i, y + 23, 18 + i, y + 23); arc(30 + i, y + 23, 0, 180, 12); ...

How To Draw a Hut in C Graphics

Image
Program : #include<stdio.h> #include<conio.h> #include<graphics.h> void main() {   int gd=0,gm;     initgraph(&gd,&gm,"C://TC//BGI"); int a[]={150,100,180,150,120,150}; //triangle on hut gate  setfillstyle(1,BROWN);  fillpoly(3,a);  int b[]={150,100,300,100,330,150,180,150};  //roof of hut   setfillstyle(4,RED);  fillpoly(4,b);   setfillstyle(1,RED);  bar(120,150,180,300);     //hut gate   setfillstyle(1,GREEN);  bar(140,220,160,300);       // small gate   setfillstyle(1,YELLOW);  bar(180,150,330,300);      //hut wall   setfillstyle(3,GREEN);   bar(230,220,270,260);    //window  getch();  } Output : For Practical implementation click on the video given below

C Graphics FLAG Program

Image
#include<stdio.h> #include<conio.h> #include<graphics.h> void main() {   int gd=0,gm;     initgraph(&gd,&gm,"C://TC//BGI"); setfillstyle(SOLID_FILL,YELLOW); bar(200,30,300,50); setfillstyle(SOLID_FILL,WHITE); bar(200,50,300,70); setfillstyle(SOLID_FILL,GREEN); bar(200,70,300,90); setcolor(BLACK); circle(250,60,10); line(250,50,250,70); line(240,60,260,60); setfillstyle(SOLID_FILL,BROWN); bar(190,25,200,350); setfillstyle(SOLID_FILL,YELLOW); fillellipse(195,355,30,5); setfillstyle(SOLID_FILL,WHITE); fillellipse(195,365,50,5); setfillstyle(SOLID_FILL,GREEN); fillellipse(195,375,70,5);  getch(); } OUTPUT : For Practical implementation click on the video given below

C Graphics Different Shapes Program

Image
#include<stdio.h> #include<conio.h> #include<graphics.h> void main() { int gd=DETECT,gm; initgraph (&gd,&gm,"C://TC//BGI"); setbkcolor(WHITE); setcolor(RED); settextstyle(8,0,2); outtextxy(210,10,"DIFFERENT SHAPES"); line(10,80,90,80); setcolor(9); outtextxy(30,90,"Line"); setcolor(RED); ellipse(200,70,10,370,70,30); outtextxy(165,95,"Ellipse"); line(400,35,300,90); line(400,35,500,90); line(300,90,500,90); outtextxy(350,95,"Triangle"); circle(65,200,60); outtextxy(30,260,"Circle"); rectangle(160,160,350,250); outtextxy(180,260,"Rectangle"); setcolor(RED); setfillstyle(SOLID_FILL,RED); bar(360,160,530,250); outtextxy(420,260,"Bar"); bar3d(10,310,125,370,10,10); outtextxy(25,380,"Bar 3D"); putpixel(250,340,RED); outtextxy(225,380,"Pixel"); arc(450,370,0,180,50); outtextxy(430,380,"Arc"); getch(); closegraph(); } ...

How to Draw A Line In C-Graphics

Image
#include<stdio.h> #include<conio.h> #include<graphics.h> void main() { int gd=DETECT,gm; initgraph(&gd,&gm,"C://TC//BGI"); line(100,200,300,400); getch(); } OUTPUT : For Practical implementation and knowing about each command of this program watch the video below.