Pages

Monday, 15 August 2016

Bouncing Ball in C Programming





#include<conio.h>
#include<graphics.h>
#include<dos.h>
#include<math.h>
#include<stdlib.h>

void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc\\bgi");
int xinc=5,yinc=5,r=10;
while(!kbhit()!=0)
{
xinc=xinc+5;
yinc=yinc+5;
r++;
if(xinc>=630)
{
xinc=-xinc;
}
if(yinc>=470)
{
yinc=-yinc;
}
if(r==25)
{
r=-r;
}
setfillstyle(1,rand());
circle(abs(xinc),abs(yinc),abs(r));
floodfill(abs(xinc),abs(yinc),WHITE);
delay(10);
cleardevice();
}
getch();
closegraph();
}




Cartoon in C Programming




#include<conio.h>
#include<graphics.h>

void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc\\bgi");
circle(320,240,100);
circle(270,210,10);
circle(370,210,10);
ellipse(320,260,0,360,8,15);
line(300,290,340,290);
arc(320,290,180,0,20);
arc(220,220,80,260,15);
arc(420,220,280,100,15);
rectangle(290,130,350,140);
arc(320,130,0,180,30);
arc(320,480,0,180,140);
arc(320,480,0,180,80);
getch();
closegraph();
}

Tiranga in C Programming



#include<conio.h>
#include<graphics.h>
#include<dos.h>

void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc\\bgi");

line(280,45,280,410);
line(290,45,290,410);
arc(285,45,0,180,5);
rectangle(250,410,320,430);
rectangle(220,430,350,450);
rectangle(190,450,380,470);
ellipse(330,55,0,180,50,5);
ellipse(430,55,180,0,50,5);

ellipse(330,95,0,180,50,5);
ellipse(430,95,180,0,50,5);

ellipse(330,135,0,180,50,5);
ellipse(430,135,180,0,50,5);

setfillstyle(1,2);
floodfill(360,115,WHITE);

ellipse(330,175,0,180,50,5);
ellipse(430,175,180,0,50,5);

ellipse(480,75,90,270,5,20);
ellipse(480,115,270,90,5,20);
ellipse(480,155,90,270,5,20);

circle(380,115,15);
circle(380,115,5);

setfillstyle(1,0);
floodfill(380,121,WHITE);

setfillstyle(1,0);
floodfill(380,115,WHITE);

setfillstyle(1,15);
floodfill(480,115,WHITE);

setfillstyle(1,3);
floodfill(480,140,WHITE);

setfillstyle(1,6);
floodfill(380,60,WHITE);

outtextxy(450,400,"Jai Hind");
outtextxy(440,415,"Created By..");
outtextxy(410,430,"Programming World");

getch();
closegraph();
}