Computer Shape Drawing with C Programming
In Following program Computer System Shape is drawn with the help of inbuilt functions available in graphics.h header file from C- language.
Program:
#include<stdio.h>
#include<graphics.h>
#include<conio.h>
#include<dos.h>
void main()
{
int gd=DETECT,gm,i;
initgraph(&gd,&gm,"c:\\turboc3\\bgi");
for(i=0;i<50;i++)
{
delay(100);
//monitor Drawing
rectangle(100,100,400,300);
setcolor(5);
rectangle(95,95,405,305);
moveto(150,150);
rectangle(230,305,260,400);
floodfill(232,307,5);
rectangle(180,400,310,450);
floodfill(183,403,5);
rectangle(182,402,308,448);
//CPU Drawing
setcolor(8);
rectangle(500,100,600,450);
rectangle(505,105,595,445);
rectangle(520,120,540,200);
rectangle(550,120,570,200);
rectangle(510,210,580,400);
floodfill(506,106,8);
line(305,450,500,450);
//mouse drawing
setcolor(6);
ellipse(400,400,0,360,15,25);
line(385,390,415,390);
line(395,390,395,375);
line(405,390,405,375);
floodfill(400,400,6);
setcolor(60-i);
outtext("WELCOME TO PROGRAMMING");
moveto(520,250);
outtext("MYG");
}
getch();
}
Output: