SlideShare a Scribd company logo
2
Most read
Code for Program to draw a circle using MidPoint Circle
Algorithm in C++ Programming
# include <iostream.h>
# include <graphics.h>
# include <conio.h>
# include <math.h>
void show_screen( );
void midpoint_circle(constint,constint,constint);
int main( )
{
int driver=VGA;
int mode=VGAHI;
int h=0;
int k=0;
int r=0;
do
{
show_screen( );
gotoxy(8,10);
cout<<"Central Point of the Circle : (h,k) :";
gotoxy(8,11);
cout<<"ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ";
gotoxy(12,13);
cout<<"Enter the value of h = ";
cin>>h;
gotoxy(12,14);
cout<<"Enter the value of k = ";
cin>>k;
gotoxy(8,18);
cout<<"Radius of the Circle : r :";
gotoxy(8,19);
cout<<"ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ";
gotoxy(12,21);
cout<<"Enter the value of r = ";
cin>>r;
initgraph(&driver,&mode,"..Bgi");
setcolor(15);
midpoint_circle(h,k,r);
setcolor(15);
outtextxy(110,460,"Press <Enter> to continue or any other key to
exit.");
int key=int(getch( ));
if(key!=13)
break;
}
while(1);
return 0;
}
/*************************************************************************/
//----------------------- midpoint_circle( ) --------------------------
///************************************************************************
*/void midpoint_circle(constint h,constint k,constint r)
{
int color=getcolor( );
int x=0;
int y=r;
int p=(1-r);
do
{
putpixel((h+x),(k+y),color);
putpixel((h+y),(k+x),color);
putpixel((h+y),(k-x),color);
putpixel((h+x),(k-y),color);
putpixel((h-x),(k-y),color);
putpixel((h-y),(k-x),color);
putpixel((h-y),(k+x),color);
putpixel((h-x),(k+y),color);
x++;
if(p<0)
p+=((2*x)+1);
else
{
y--;
p+=((2*(x-y))+1);
}
}
while(x<=y);
}
/*************************************************************************/
//-------------------------- show_screen( ) ---------------------------
///************************************************************************
*/void show_screen( )
{
restorecrtmode( );
textmode(C4350);
cprintf("n****************************************************************
****************");
cprintf("*-***********************- -
**********************-*");
cprintf("*------------------------- ");
textbackground(1);
cprintf(" MidPoint Circle Algorithm ");
textbackground(8);
cprintf(" ------------------------*");
cprintf("*-***********************- -
**********************-*");
cprintf("*-
***************************************************************************
*-*");
for(int count=0;count<42;count++)
cprintf("*-*
*-*");
gotoxy(1,46);
cprintf("*-
***************************************************************************
*-*");
cprintf("*----------------------------------------------------------
--------------------*");
cprintf("******************************************************************
**************");
gotoxy(1,2);
}
Ad

Recommended

Code
Code
Lay Chan Dara Raksmey
 
C++ assignment
C++ assignment
Zohaib Ahmed
 
CSC – 184 Programming C
CSC – 184 Programming C
ABIR A HAPZU
 
Program of bar 3 d
Program of bar 3 d
sonamr123
 
Include
Include
Angie Borda
 
Project code for Project on Student information management system
Project code for Project on Student information management system
REHAN IJAZ
 
PROGRAM FOR INSERTION SORTING IN ARRAY
PROGRAM FOR INSERTION SORTING IN ARRAY
daemian2
 
C++ Programming - 3rd Study
C++ Programming - 3rd Study
Chris Ohk
 
Clock For My
Clock For My
shamalanamnam
 
Assignement c++
Assignement c++
Syed Umair
 
11 1 포인터
11 1 포인터
Changwon National University
 
Assignement of programming & problem solving ass.(3)
Assignement of programming & problem solving ass.(3)
Syed Umair
 
Programming in c
Programming in c
edmspjp
 
C++ Programming - 4th Study
C++ Programming - 4th Study
Chris Ohk
 
C++ Programming - 2nd Study
C++ Programming - 2nd Study
Chris Ohk
 
Pratik Bakane C++
Pratik Bakane C++
pratikbakane
 
Practical no 1
Practical no 1
Kshitija Dalvi
 
Ruby haskell extension
Ruby haskell extension
Toshiyuki Terashita
 
Cpp c++ 2
Cpp c++ 2
Sltnalt Cosmology
 
cosc 281 hw2
cosc 281 hw2
Brian Goggins
 
135
135
Muhammad Jasim
 
Programa.eje
Programa.eje
guapi387
 
Basic Programs of C++
Basic Programs of C++
Bharat Kalia
 
Pratik Bakane C++
Pratik Bakane C++
pratikbakane
 
C++ programs
C++ programs
Mukund Gandrakota
 
Ques 8
Ques 8
VidhiPatel221
 
Oops in c++
Oops in c++
DravidSh
 
Computer Engineering (Programming Language: Swift)
Computer Engineering (Programming Language: Swift)
Sethmi Kachchakaduge
 
bfd23fd7-0d89-45c0-8b82-c991b30ed375.pdf
bfd23fd7-0d89-45c0-8b82-c991b30ed375.pdf
shehabhamad_90
 
C++ Programming - 1st Study
C++ Programming - 1st Study
Chris Ohk
 

More Related Content

What's hot (20)

Clock For My
Clock For My
shamalanamnam
 
Assignement c++
Assignement c++
Syed Umair
 
11 1 포인터
11 1 포인터
Changwon National University
 
Assignement of programming & problem solving ass.(3)
Assignement of programming & problem solving ass.(3)
Syed Umair
 
Programming in c
Programming in c
edmspjp
 
C++ Programming - 4th Study
C++ Programming - 4th Study
Chris Ohk
 
C++ Programming - 2nd Study
C++ Programming - 2nd Study
Chris Ohk
 
Pratik Bakane C++
Pratik Bakane C++
pratikbakane
 
Practical no 1
Practical no 1
Kshitija Dalvi
 
Ruby haskell extension
Ruby haskell extension
Toshiyuki Terashita
 
Cpp c++ 2
Cpp c++ 2
Sltnalt Cosmology
 
cosc 281 hw2
cosc 281 hw2
Brian Goggins
 
135
135
Muhammad Jasim
 
Programa.eje
Programa.eje
guapi387
 
Basic Programs of C++
Basic Programs of C++
Bharat Kalia
 
Pratik Bakane C++
Pratik Bakane C++
pratikbakane
 
C++ programs
C++ programs
Mukund Gandrakota
 
Ques 8
Ques 8
VidhiPatel221
 
Oops in c++
Oops in c++
DravidSh
 
Computer Engineering (Programming Language: Swift)
Computer Engineering (Programming Language: Swift)
Sethmi Kachchakaduge
 

Similar to Code for program to draw a circle using mid point circle algorithm in c (20)

bfd23fd7-0d89-45c0-8b82-c991b30ed375.pdf
bfd23fd7-0d89-45c0-8b82-c991b30ed375.pdf
shehabhamad_90
 
C++ Programming - 1st Study
C++ Programming - 1st Study
Chris Ohk
 
54602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee01083101
premrings
 
C++ file
C++ file
simarsimmygrewal
 
Bijender (1)
Bijender (1)
Ankush Kumar
 
Managing console
Managing console
Shiva Saxena
 
C++ file
C++ file
Mukund Trivedi
 
C++ file
C++ file
Mukund Trivedi
 
C++
C++
Raj vardhan
 
graphics ss.pdf
graphics ss.pdf
shehabhamad_90
 
Billing in a supermarket c++
Billing in a supermarket c++
varun arora
 
computer graphics practicals
computer graphics practicals
Manoj Chauhan
 
2014 computer science_question_paper
2014 computer science_question_paper
vandna123
 
Oops practical file
Oops practical file
Ankit Dixit
 
Problemas de Arreglos en c++
Problemas de Arreglos en c++
Manfred Ariel Martinez Bastos
 
Computer Networks Lab File
Computer Networks Lab File
Kandarp Tiwari
 
Pads lab manual final
Pads lab manual final
AhalyaR
 
Cs pritical file
Cs pritical file
Mitul Patel
 
Pattern printing-in-c(Jaydip Kikani)
Pattern printing-in-c(Jaydip Kikani)
Jaydip JK
 
Graphics in C++
Graphics in C++
Ahsan Mughal
 
bfd23fd7-0d89-45c0-8b82-c991b30ed375.pdf
bfd23fd7-0d89-45c0-8b82-c991b30ed375.pdf
shehabhamad_90
 
C++ Programming - 1st Study
C++ Programming - 1st Study
Chris Ohk
 
54602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee01083101
premrings
 
Billing in a supermarket c++
Billing in a supermarket c++
varun arora
 
computer graphics practicals
computer graphics practicals
Manoj Chauhan
 
2014 computer science_question_paper
2014 computer science_question_paper
vandna123
 
Oops practical file
Oops practical file
Ankit Dixit
 
Computer Networks Lab File
Computer Networks Lab File
Kandarp Tiwari
 
Pads lab manual final
Pads lab manual final
AhalyaR
 
Cs pritical file
Cs pritical file
Mitul Patel
 
Pattern printing-in-c(Jaydip Kikani)
Pattern printing-in-c(Jaydip Kikani)
Jaydip JK
 
Ad

Recently uploaded (20)

Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Rajdeep Bavaliya
 
BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024
BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024
Quiz Club of PSG College of Arts & Science
 
Publishing Your Memoir with Brooke Warner
Publishing Your Memoir with Brooke Warner
Brooke Warner
 
How to Create an Event in Odoo 18 - Odoo 18 Slides
How to Create an Event in Odoo 18 - Odoo 18 Slides
Celine George
 
LDMMIA GRAD Student Check-in Orientation Sampler
LDMMIA GRAD Student Check-in Orientation Sampler
LDM & Mia eStudios
 
How to Manage Multi Language for Invoice in Odoo 18
How to Manage Multi Language for Invoice in Odoo 18
Celine George
 
Revista digital preescolar en transformación
Revista digital preescolar en transformación
guerragallardo26
 
ABCs of Bookkeeping for Nonprofits TechSoup.pdf
ABCs of Bookkeeping for Nonprofits TechSoup.pdf
TechSoup
 
ICT-8-Module-REVISED-K-10-CURRICULUM.pdf
ICT-8-Module-REVISED-K-10-CURRICULUM.pdf
penafloridaarlyn
 
BINARY files CSV files JSON files with example.pptx
BINARY files CSV files JSON files with example.pptx
Ramakrishna Reddy Bijjam
 
Overview of Off Boarding in Odoo 18 Employees
Overview of Off Boarding in Odoo 18 Employees
Celine George
 
How to Manage Upselling of Subscriptions in Odoo 18
How to Manage Upselling of Subscriptions in Odoo 18
Celine George
 
Wax Moon, Richmond, VA. Terrence McPherson
Wax Moon, Richmond, VA. Terrence McPherson
TerrenceMcPherson1
 
JHS SHS Back to School 2024-2025 .pptx
JHS SHS Back to School 2024-2025 .pptx
melvinapay78
 
Basic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Basic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Restu Bias Primandhika
 
Measuring, learning and applying multiplication facts.
Measuring, learning and applying multiplication facts.
cgilmore6
 
“THE BEST CLASS IN SCHOOL”. _
“THE BEST CLASS IN SCHOOL”. _
Colégio Santa Teresinha
 
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
Arshad Shaikh
 
Sustainable Innovation with Immersive Learning
Sustainable Innovation with Immersive Learning
Leonel Morgado
 
Introduction to Generative AI and Copilot.pdf
Introduction to Generative AI and Copilot.pdf
TechSoup
 
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Rajdeep Bavaliya
 
Publishing Your Memoir with Brooke Warner
Publishing Your Memoir with Brooke Warner
Brooke Warner
 
How to Create an Event in Odoo 18 - Odoo 18 Slides
How to Create an Event in Odoo 18 - Odoo 18 Slides
Celine George
 
LDMMIA GRAD Student Check-in Orientation Sampler
LDMMIA GRAD Student Check-in Orientation Sampler
LDM & Mia eStudios
 
How to Manage Multi Language for Invoice in Odoo 18
How to Manage Multi Language for Invoice in Odoo 18
Celine George
 
Revista digital preescolar en transformación
Revista digital preescolar en transformación
guerragallardo26
 
ABCs of Bookkeeping for Nonprofits TechSoup.pdf
ABCs of Bookkeeping for Nonprofits TechSoup.pdf
TechSoup
 
ICT-8-Module-REVISED-K-10-CURRICULUM.pdf
ICT-8-Module-REVISED-K-10-CURRICULUM.pdf
penafloridaarlyn
 
BINARY files CSV files JSON files with example.pptx
BINARY files CSV files JSON files with example.pptx
Ramakrishna Reddy Bijjam
 
Overview of Off Boarding in Odoo 18 Employees
Overview of Off Boarding in Odoo 18 Employees
Celine George
 
How to Manage Upselling of Subscriptions in Odoo 18
How to Manage Upselling of Subscriptions in Odoo 18
Celine George
 
Wax Moon, Richmond, VA. Terrence McPherson
Wax Moon, Richmond, VA. Terrence McPherson
TerrenceMcPherson1
 
JHS SHS Back to School 2024-2025 .pptx
JHS SHS Back to School 2024-2025 .pptx
melvinapay78
 
Basic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Basic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Restu Bias Primandhika
 
Measuring, learning and applying multiplication facts.
Measuring, learning and applying multiplication facts.
cgilmore6
 
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
Arshad Shaikh
 
Sustainable Innovation with Immersive Learning
Sustainable Innovation with Immersive Learning
Leonel Morgado
 
Introduction to Generative AI and Copilot.pdf
Introduction to Generative AI and Copilot.pdf
TechSoup
 
Ad

Code for program to draw a circle using mid point circle algorithm in c

  • 1. Code for Program to draw a circle using MidPoint Circle Algorithm in C++ Programming # include <iostream.h> # include <graphics.h> # include <conio.h> # include <math.h> void show_screen( ); void midpoint_circle(constint,constint,constint); int main( ) { int driver=VGA; int mode=VGAHI; int h=0; int k=0; int r=0; do { show_screen( ); gotoxy(8,10); cout<<"Central Point of the Circle : (h,k) :"; gotoxy(8,11); cout<<"ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ"; gotoxy(12,13); cout<<"Enter the value of h = "; cin>>h; gotoxy(12,14); cout<<"Enter the value of k = "; cin>>k; gotoxy(8,18); cout<<"Radius of the Circle : r :"; gotoxy(8,19); cout<<"ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ"; gotoxy(12,21); cout<<"Enter the value of r = "; cin>>r; initgraph(&driver,&mode,"..Bgi"); setcolor(15); midpoint_circle(h,k,r); setcolor(15); outtextxy(110,460,"Press <Enter> to continue or any other key to exit."); int key=int(getch( ));
  • 2. if(key!=13) break; } while(1); return 0; } /*************************************************************************/ //----------------------- midpoint_circle( ) -------------------------- ///************************************************************************ */void midpoint_circle(constint h,constint k,constint r) { int color=getcolor( ); int x=0; int y=r; int p=(1-r); do { putpixel((h+x),(k+y),color); putpixel((h+y),(k+x),color); putpixel((h+y),(k-x),color); putpixel((h+x),(k-y),color); putpixel((h-x),(k-y),color); putpixel((h-y),(k-x),color); putpixel((h-y),(k+x),color); putpixel((h-x),(k+y),color); x++; if(p<0) p+=((2*x)+1); else { y--; p+=((2*(x-y))+1); } } while(x<=y); } /*************************************************************************/ //-------------------------- show_screen( ) --------------------------- ///************************************************************************ */void show_screen( ) { restorecrtmode( ); textmode(C4350); cprintf("n**************************************************************** ****************"); cprintf("*-***********************- - **********************-*"); cprintf("*------------------------- ");
  • 3. textbackground(1); cprintf(" MidPoint Circle Algorithm "); textbackground(8); cprintf(" ------------------------*"); cprintf("*-***********************- - **********************-*"); cprintf("*- *************************************************************************** *-*"); for(int count=0;count<42;count++) cprintf("*-* *-*"); gotoxy(1,46); cprintf("*- *************************************************************************** *-*"); cprintf("*---------------------------------------------------------- --------------------*"); cprintf("****************************************************************** **************"); gotoxy(1,2); }