Ad Code

Creating Indian Flag Using Computer Graphics in C Programming.

Indian Flag Graphics Program

In this tutorial, we will learn how to create the Indian flag using computer graphics in the C programming language. The Indian flag is made up of three horizontal rectangles, each in a different color, and a navy blue wheel with 24 spokes in the center.

To draw the rectangles, we will use the rectangle() function in the graphics.h library, which takes four arguments: the x-coordinate and y-coordinate of the upper left corner of the rectangle, and the x-coordinate and y-coordinate of the lower right corner of the rectangle. We will also use the setfillstyle() function to set the fill pattern of each rectangle.

For the navy blue wheel, we will use the circle() function to draw a circle, and then draw the spokes using the line() function. Finally, we will use the setcolor() function to set the color of each element, and the floodfill() function to fill in the appropriate areas with color.

This program is a great way to practice using graphics functions in C, and also allows us to create a patriotic and meaningful image.

Program :

  #include<stdio.h>
  #include<conio.h>
  #include<graphics.h>
  #include<math.h>
  #include<dos.h>
  int main()
  {
  int gd=DETECT,gm,i,x,y;
  float pi=3.14;
  initgraph(&gd,&gm,"C:\\TC\\BGI");
  setcolor(RED);
  rectangle(155,150,455,200);
  setfillstyle(SOLID_FILL,RED);
  floodfill(156,151,4);
  setcolor(WHITE);
  setfillstyle(SOLID_FILL,WHITE);
  rectangle(155,200,455,250);
  floodfill(156,201,WHITE);
  setcolor(GREEN);
  setfillstyle(SOLID_FILL,GREEN);
  rectangle(155,250,455,300);
  floodfill(156,251,GREEN);
  setcolor(BLUE);
  circle(305,225,25);
  setcolor(WHITE);
  settextstyle(1,0,5);
  outtextxy(260,350,"INDIA");
  for(i=0;i<360;i=i+10)
  {
  x=25*cos(i*pi/180);
  y=25*sin(i*pi/180);
  setcolor(BLUE);
  line(305,225,305+x,225-y);
  delay(150);
  }
  getch();
  }

Output:


So, Copy this program and use it in your computer. Enjoy !!

Post a Comment

0 Comments

Ad Code