ANIMATE
A CAR
AIM:
To write a c program to animate a car
ALGORITHM:
·
Include
the header files
·
Initialize
the variables i,a=1;
·
Using
a for loop to increment i values of a
line and arc
·
Set
a color using setcolor with a as parameter
·
Increment
a
·
Stop
the program
CODINGS:
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int i,a=1;
int gd=DETECT,gm;
initgraph(&gd,&gm,"");
cleardevice();
setbkcolor(BLACK);
for(i=1;i<=600;i++)
{
line(90+i,250,150+i,250);
line(90+i,250,60+i,280);
line(150+i,250,180+i,280);
line(30+i,280,210+i,280); line(210+i,280,210+i,310);
line(30+i,310,210+i,310);
line(30+i,280,30+i,310);
arc(85+i,310,180,360,15);
arc(155+i,310,180,360,15); arc(85+i,310,180,360,14);
arc(155+i,310,180,360,14);
arc(85+i,310,180,360,9);
arc(155+i,310,180,360,9);
arc(85+i,310,180,360,10);
arc(155+i,310,180,360,10);
line(100+i,255,125+i,255);
line(100+i,255,75+i,280);
line(125+i,255,140+i,255);
line(125+i,255,125+i,280);
line(142+i,255,165+i,280);
circle(140+i,270,5);
setcolor(a);
line(143+i,273,143+i,280);
line(139+i,273,139+i,280);
delay(150);
i=i+5;
a++;
cleardevice();
}
getch();
}
OUTPUT:
RESULT:
Thus, the program has been successfully
executed & output is verified.
No comments:
Post a Comment