Creat Indian Flag Using C & C++ Or Codeblocks Programing

in #creat6 years ago

How Creat Indian National Flag Using C & C++ Programing:

Hello Friends. How Are You I think You are good .
Today I will Show You How Creat Indian National Flag using Turbo C&C++ Or Codeblocks..
Indian flag C/C++ Project tutorial and guide for developing code.
Indian flag Screen Shot.
We have project collection of C/C++ with source code.

So Lets Start ..

Step By Step…
1.first need a Computer Or Laptop.
2.Need Turbo/codeblocks
3.open this apps.
and write This program….

I will Show Practically. first i creat this flag then i give screenshot.
Program Is Here...

How Creat Indian national Flag Using C&C++ and codeblocks.

#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;

Or.
You Can Use This Code...

#include "afxwin.h"
#include <math.h>

class CMyApp : public CWinApp
{
public:
virtual BOOL InitInstance ();
};

class CMainWindow : public CFrameWnd
{
public:
CMainWindow();
protected:
afx_msg void OnPaint();
DECLARE_MESSAGE_MAP();
};

CMyApp myAPP;

BOOL CMyApp::InitInstance()
{
m_pMainWnd = new CMainWindow;
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
return TRUE;
}

BEGIN_MESSAGE_MAP (CMainWindow, CFrameWnd)
ON_WM_PAINT()
END_MESSAGE_MAP()

CMainWindow::CMainWindow ()
{
Create(NULL,_T("India's Flag"), WS_OVERLAPPEDWINDOW );
}
void IndiaFlag(CDC &dc, int x, int y)
{
dc.SetBkMode(TRANSPARENT);
CRect rect;
CPen pen(PS_SOLID, 1, RGB(0,0,0));
CPen *oldPen = dc.SelectObject(&pen);
{
CBrush brush(RGB(255,130,0));
CBrush *oldBrush = dc.SelectObject(&brush);
dc.Rectangle(x,y,x+200,(y+50));
}
{
CBrush brush(RGB(255,255,255));
CBrush *oldBrush = dc.SelectObject(&brush);
dc.Rectangle(x,(y+50),(x+200),(y+100));
CPen pen2(PS_SOLID, 1,RGB(0,0,255));
CPen oldPen = dc.SelectObject(&pen2);
dc.Ellipse((x+75),(y+50),(x+125),(y+100));
double Nx,Ny;
for (int angle=0;angle<360; angle+=15)
{
int angle2 = angle;
double length = 25
(cos(double(angle2 (3.14159265 / 180))));
double len2 = 25
(sin(double(angle2 *(3.14159265 / 180))));
int originX = (x+100);
int originY = (y+75);
Nx = originX + length;
Ny = originY - len2;
dc.MoveTo(originX,originY);
dc.LineTo(Nx,Ny);
}
}
{
CBrush brush(RGB(34,139,34));
CBrush *oldBrush = dc.SelectObject(&brush);
dc.Rectangle(x,(y+100),(x+200),(y+150));
}
}
void CMainWindow::OnPaint ()
{
CPaintDC dc(this);
IndiaFlag(dc, 150, 150);
}