Mar 13, 2007

C++ program to draw concentric circles

C++ program to generate concentric circles. Here For loop will give radius (i) to circle function and each time it will increment by 5.Delay function will slow down the process to print the concentric circles on the screen. For initgraph() function and circle() function graphics.h header file is used the function initgraph() will convert text mode to graphics mode and closegraph() again converts graphics screen into text mode.In initgraph function third parameter is path of BGI files where graphics files are located. If the graphics driver files are other than this directory than type that path as a third parameter in initgraph() function. Many time we run a graphics program and often a BGI error occurres. It is related to this path of BGI files. Give correct path of BGI files in initgraph() function. If you don't know the path of BGI files then find *.BGI files by find option in winodws and you will be known the correct path.

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

main()
{
clrscr();
int driver,mode;
driver = DETECT;
initgraph(&driver,&mode,"C:\TC\BGI");
for(int i=1;i<=50;i=i+5)
{
circle(100,100,i);
delay(100);
}
getch();
closegraph();
}

No comments:

Post a Comment

Infolinks In Text Ads

Total Pageviews

Powered by Blogger.

Dont Forget To Follow Us

Blog Archive