
Programs Using Library Functions 853
restorecrtmode();
return 0;
}
Explanation: This program draws the rectangle using the given arguments. The setcolor() sets
the color of the rectangle.
7. Use of setviewport(), outtextxy() and setcolor():
22.9 Use setviewport(), outtextxy(), setcolor() , closegraph() and display some message
in 15 different colors.
#include<stdio.h>
#include<conio.h>
#include<iostream.h>
#include<graphics.h>
int main()
{
int gd =DETECT,gm,j;
initgraph(&gd,&gm,“c:\\tc\\bgi”);
char st[50];
clrscr();
setviewport(00,00,400,400,1);
outtextxy(10,10,“View port”);
for(j=1;j<=15;j++)
{
setcolor(j);
sprintf(st,“Existing Color ...