C++ program to print Indian flag














































C++ program to print Indian flag



Program:
#include<stdio.h>

#include<graphics.h>

#include<math.h>

int gd,gm;

int main()

{

float PI=3.14;

int r,i,a,b,x,y;

initgraph(&gd,&gm,"C:\TURBOC3\BGI");

detectgraph(&gd,&gm);

setcolor(RED);

//draw the top rectangle and color it

floodfill(101,101,RED);

rectangle(100,100,450,150);

setfillstyle(SOLID_FILL,RED);

rectangle(100,150,450,200);

//draw the middle rectangle and color it

setcolor(WHITE);

rectangle(100,200,450,250);

setfillstyle(SOLID_FILL,WHITE);

floodfill(101,151,WHITE);

//draw the bottom rectangle and color it

setcolor(GREEN);

r=25; //radius

setfillstyle(SOLID_FILL,GREEN);

floodfill(101,201,GREEN);

a=275; //center

//draw the circle

b=175; //center

line(a,b,a+x,b-y);

setcolor(BLUE);

circle(a,b,r);

for(i=0;i<=360;i=i+15)

//spokes

{

y=rsin(iPI/180);

x=rcos(iPI/180);

}

}

getch();

closegraph();

return 0;
}
Output:



More Articles of Shaik Aftab Ahmed:

Name Views Likes
C++ Program to Find the Frequency of Odd & Even Numbers in the given Matrix 340 1
C++ program to Sort a Linked List Using Merge Sort 316 1
C++ Program to Implement a Linked List representation of a Binary tree 294 1
C++ Program to Check for balanced parentheses in an expression 199 1
C++ Program to Perform Inorder, Preorder, Postorder traversals in a binary tree. 246 1
C++ program to print Indian flag 290 1
C++ program to Convert a multi level linked list to a singly linked list 201 1
C++ program to print right view of a Binary tree using queue 213 1
C++ Program to implement Huffman Coding Compression Algorithm 1257 1
C++ Program to Create a Height Balanced Binary Tree 241 1
C++ program to implement Prims algorithm 408 1
C++ Program for BFS Traversal 256 1
C++ Progam to Evaluate a Prefix Expression 296 1
C++ Program to Implement Queue using Linked List 224 1
C++ implementation of Stack using Linked list 247 1
C++ program to find the intersection point of two linked lists 288 1
C++ program to count the inversions in the given array 251 1
C++ program to perform D.N.F sort 293 1
C++ program to print all possible subsets of a String 260 1
C++ program to count the number of ones in a binary representation of a number 283 1
C++ program to print all possible subsets of a set 294 1
C++ program to find the largest word in a String 264 1
C++ Program to print a matrix in Spiral order 307 1
C++ program to convert from Binary to Decimal, Octal to Decimal, Hexadecimal to Decimal 277 1
C limits library 311 1
Program to add two Binary numbers 296 1

Comments