Sunday, 8 June 2014

Wave (1)

Output


// PROGRAM TO DRAW WAVE  (1)

// SAVE PROGRAM WITH EXTENSION  .CPP  OR DECLARE ALL VARIABLES
//  AT THE BEGIN OF MAIN FUNCTION

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

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

int x = getmaxx();
int y = getmaxy();

int rad_x = 25;
int rad_y = 50;

int start_x = rad_x;
int start_y = y/2;

int flag=0;
setcolor(RED);
setbkcolor(WHITE);

while(1)
{
if(start_x >= x)
{
delay(50);
getch();
closegraph();
exit(0);
}

if(flag==0)
{
for(int i=180; i>=0; i--)
{
// FOR MULTY COLOR WAVE REMOVE setcolor() COMMENT
//setcolor(i);
ellipse(start_x, start_y, i, i+1, rad_x, rad_y);
delay(10);
}
flag = 1;
}
else
{
for(int j=180; j<=360; j++)
{
// FOR MULTY COLOR WAVE REMOVE setcolor() COMMENT
//setcolor(j);
ellipse(start_x, start_y, j, j+1, rad_x, rad_y);
delay(10);
}
flag = 0;
}
start_x = start_x + (rad_x * 2 - 1);
}
}

No comments:

Post a Comment