circle() Function in C Graphics – Syntax and Example

Introduction to circle() Function

The circle() function is used to draw a circle on the graphics screen. It requires three parameters: the X-coordinate of the centre, the Y-coordinate of the centre, and the radius of the circle. The circle() function is available in the traditional BGI (Borland Graphics Interface) graphics library through the graphics.h header file.

circle() फंक्शन का उपयोग ग्राफिक्स स्क्रीन पर वृत्त (Circle) बनाने के लिए किया जाता है। इसमें तीन पैरामीटर की आवश्यकता होती है: वृत्त के केंद्र का X-coordinate, केंद्र का Y-coordinate तथा वृत्त की त्रिज्या (Radius)। circle() फंक्शन पारंपरिक BGI (Borland Graphics Interface) ग्राफिक्स लाइब्रेरी में उपलब्ध होता है, जिसके लिए graphics.h हेडर फाइल का उपयोग किया जाता है।

Syntax of circle() Function

void circle(int x, int y, int radius);

Parameters:

  • x: X-coordinate of the centre of the circle.

  • y: Y-coordinate of the centre of the circle.

  • radius: Radius of the circle.

पैरामीटर्स:

  • x: वृत्त के केंद्र का X-coordinate।

  • y: वृत्त के केंद्र का Y-coordinate।

  • radius: वृत्त की त्रिज्या (Radius)।

Example: C Program to Draw a Circle Using circle() Function

The following program demonstrates how to draw a circle with its centre at (200, 150) and radius of 80 pixels.

निम्न प्रोग्राम में (200, 150) को वृत्त का केंद्र तथा 80 को उसकी त्रिज्या मानकर एक वृत्त बनाया गया है।

#include <graphics.h>
#include <conio.h>
int main(void)
{
int gd = DETECT, gm;
initgraph(&gd, &gm, "C:\\TC\\BGI");
circle(200, 150, 80);
getch();
closegraph();
return 0;
}

Output:

A graphics window appears showing a circle with its centre at (200, 150) and radius of 80 pixels.

ग्राफिक्स विंडो में (200, 150) केंद्र तथा 80 पिक्सेल त्रिज्या वाला एक वृत्त दिखाई देगा।

Important Points About circle() Function

  1. The circle() function requires three parameters: centre X-coordinate, centre Y-coordinate and radius.

    circle() फंक्शन में तीन पैरामीटर होते हैं: केंद्र का X-coordinate, केंद्र का Y-coordinate तथा त्रिज्या।

  2. The radius is the distance from the centre of the circle to its boundary.

    त्रिज्या वृत्त के केंद्र से उसकी बाहरी सीमा तक की दूरी होती है।

  3. The diameter of a circle is twice its radius.

    वृत्त का व्यास उसकी त्रिज्या का दोगुना होता है। Diameter = 2 * Radius

  4. The circle() function draws only the outline of the circle. It does not fill the circle with color automatically.

    circle() फंक्शन केवल वृत्त की बाहरी सीमा बनाता है। यह अपने आप वृत्त में रंग नहीं भरता है।

  5. The circle() function belongs to the BGI graphics library and is not a standard C function.

    circle() फंक्शन BGI ग्राफिक्स लाइब्रेरी का हिस्सा है, यह Standard C का फंक्शन नहीं है।

Note for Modern C Compilers

The above program is written for the traditional Turbo C/BGI graphics environment. The graphics.h library and functions such as initgraph(), circle() and closegraph() are not provided by standard C compilers such as GCC by default.

ऊपर दिया गया प्रोग्राम पारंपरिक Turbo C/BGI ग्राफिक्स वातावरण के लिए है। graphics.h लाइब्रेरी तथा initgraph(), circle() और closegraph() जैसे फंक्शन GCC जैसे आधुनिक C कंपाइलर में डिफॉल्ट रूप से उपलब्ध नहीं होते हैं।

Comments

Popular posts from this blog

C Language Topics in Hindi and English

Complete C Programming Syllabus | Advanced C Roadmap for Students

Top High-Paying Tech Skills to Learn in 2025