Sample – Program to draw 2 rectangles and fill 1 of them.
by Nideesh C on February 8, 2011 · 0 comments
in C++
#include <iostream.h>
#include <conio.h>
#include <graphics.h>
#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
void main()
{
clrscr();
int gd = DETECT,gm,errorcode; //Requesting auto-detection.
//Initializing graphics and local variables.
initgraph (&gd, &gm, “d:\\bc3\\bgi”); //Path where graphics drivers are installed
//Read result of initialization.
errorcode = graphresult();
//An error occured.
if (errorcode != grOk)
{
cout << “Graphics error occured : \n” << grapherrormsg(errorcode) << endl;
cout << “Press any key to stop : “;
getch();
exit(1);
}
/*Drawing a rectangle having top LHS vertex at (300, 300)
and bottom RHS vertex at (600, 400)*/
rectangle(300, 300, 600, 400);
rectangle(100, 100, 200, 200);
getch();
floodfill(120, 120, WHITE);
getch();
closegraph();
}
This graphics program draws two rectangles, but fills in only one of them with a white color using the ‘floodfill’ command.
Not Satisfied ? Just search & get the result
Related posts:
- Sample – Program to enter an integer and print out its successor.
- Sample – Program to enter a string and find its length.
- Sample – Program to enter an integer and output the cube of that integer.
- Sample program (multiplication using addition)
- Sample – understanding life time and scope
Tagged as:
c programming examples,
c programming reference,
c tutorial,
c++ program examples,
C++ Programming,
learning c++,
Program to draw 2 rectangles and fill 1 of them.,
programming languages,
programming languages c,
sample c++ programs
Me, freelance system administrator having the qualification of Diploma in Electronics & Tele-communication + MCSE + CCNA + CST + 5 years of experience in IT field.
If you like This post, you can follow TheOnlineTutorials on Twitter.
Contact me Via email: support@theonlinetutorials.com
Subscribe to feed via Feed or EMAIL to receive instant updates.
Legal Disclaimer:All information found on the site is without any implied warranty of fitness for any purpose or use whatsoever. Content author/site administrator is not responsible for any loss occurred due to mistakes in this tutorial. Use this tutorial website at your own risk.