C program to Draw A rainbow
Creating a Rainbow using Graphics Programming in C
#include<stdio.h>
#include<graphics.h>
#include<dos.h>// function for making of rainbow
void rainbow()
{// auto detection
int gdriver = DETECT,gmode;
int x, y, i;initgraph(&gdriver,&gmode,”C:\\Turboc3\\BGI“);
// message
printf(“\nThis is a Rainbow“);
//for background color
setbkcolor(BLUE+WHITE);//finding centre x-ordinate of screen
x = getmaxx() / 2;
//finding centre y-ordinate of screen
y = getmaxy() / 2;for (i=30; i<200; i++)
{delay(100);
// select color for making of rainbow
setcolor(i/10);//arc making with fixed centre and increasing radius
arc(x, y, 0, 180, i-10);
}
}
// driver program
int main()
{
rainbow();
return 0;
}
Example of graphics program in C
Graphics program in c examples pdf
Download PDFExplanation of Graphics Program
(initgraph);- This function is used for initializing graphics mode(were passed three arguments to
initgraph function)
&gdriver:-This is the address of gdriver (Graphics Driver) variable.
&gmode:- This is the address of gmode (Graphics Mode)
“C:\\Turboc3\\BGI”:- This is the directory path where BGI files are stored, This directory only work with Turbo C (DOS) Editor.
delay();- delay function stored under dos.h for holding the
function for some time.
Write a C program To draw Rainbow
C program to draw a square using graphics (clickHere)
Full Circle wise Rainbow Program (clickHere)
Note:- Maybe sometime above code doesn’t get user-friendly output, in codeblock ‘or’ any other EDITOR, All of C & C++ program tested in DOS compiler Turbo C.
Also Read
Types of functions in C Read Here
I hope you will understand better if you study at M.U, in the exam of M.U you know how important this “C program to draw a A rainbow using graphics” . So please don’t forget to give your valuable feedback. Go in the comment section and Give us some feedback about it. C program to draw a A rainbow or My website.
Our team check your every Comment per day Because your one feedback helps us in growing Thesmolt
I request you if you have any doubt or question regarding our site, then please don’t hesitate. We always waiting for your Suggestion.
Note:- If you want to Download This article’s in PDF form, then simply go (Top or Bottom of) Right corner and click on the PRINT icon, and it’s saved as a PDF of C program to draw a A rainbow
For further questions, you can contact us Via mail [email protected] otherwise, Our Help Page and Contact us Page, which is included below. I hope I’ll able to say all the possible ways to reach us. Or Download My Android Application Below Download Button.