Making circle in C++ without using and Graphics libraies

Making a circle or any geometrical object by using graphics libraries is not a big deal but if we can create the geometrical object without using any graphics libraries is a little bit tricky.
Today, I made a circle without using any graphics libraries. This can be done by using the two-dimensional array and parametric equation of a circle. Here is the given below code:


using namespace std;

int main(){
    int width = 80, height = 25, radius;
    char ch;
    cout << "Enter the radius of circles less than or equal to 12: "; cin >> radius;
    cout << "\nEnter the character by which you make a circle: "; cin >>  ch;   

    // Initialise a two dimensional array
    char display[width][height];

    // Create a empty display 
    for(int i = 0; i < height; i++){
        for(int j = 0; j < width; j++){
           display[i][j] = ' '; // Every element of display equal to empty
    // Create a circle by using parametric equations of circle
    for(int angle = 0; angle < 360; angle += 1){
        // Calculate x and y by using parametic formulas of circle
        int x = (radius * cos(angle)); 
        int y = (radius * sin(angle));
        // Moving cordinates toward center of the display
        int cx = height/2 + x;
        int cy = width/2 + y;
        // Character which made the circle
        display[cx][cy] = ch;

    // Display all elements present in display array
    for(int i = 0; i < height; i++){
        for(int j = 0; j < width; j++){
           cout << display[i][j];
        cout << endl;

    return 0;


FollowFollow on FacebookFollow on Google+Email this to someone

Leave a Reply

Your email address will not be published. Required fields are marked *