C++C++11C++14C++17Learn C++

Tutorial: Learn To Print Mandelbrot In Text Form In C++

In mathematics, fractals are a self-similar subset of Euclidean space whose fractal dimensions strictly exceeds its topological dimension. So when you draw these functions in their topological height, fractals appear the same at different levels, as illustrated in successive magnifications of the Mandelbrot set.

Mandelbrot set is a good example to see how fractals are changing in every x,y and z planes. Drawing a Mandelbrot set exhibit an elaborate and infinitely complicated boundary that reveals progressively ever-finer recursive details at increasing zooming that makes the boundary of the Mandelbrot set as in fractal curves. The Mandelbrot set basically defined as a function of f(z)=z^2+c where z and c are complex numbers.

C++ Builder is easy to draw or print these kind of graphics, it includes compilers for Win32, Win64, Android and iOS. C++Builder has both CLANG Enhanced C/C++ Compiler and a Borland C/C++ Compiler. It also features a modern, high-productivity RAD Studio IDE, debugger tools, and enterprise connectivity for to accelerate cross-platform UI development. You can develop GUI based applications easily, as it comes with the award-winning VCL framework for high-performance native Windows apps and the powerful FireMonkey (FMX) framework for cross-platform UIs. There is a free C++ Builder Community Edition that can be used by students, beginners and startups with limitations.

You can download Free the C++ Builder Community Edition (CE) here: https://www.embarcadero.com/products/cbuilder/starter.
Professional developers can use the Professional, Architect or Enterprise versions of C++ Builder. You can download and use the trial version for one month with the same capabilities as the full version . Please visit https://www.embarcadero.com/products/cbuilder.

In this post we want to show you how you can printout a Mandelbrot set in text form in C++ Builder. While we are able to draw as shown above in graphics we want to have fun with printing it in text form.

1.Create a new Multi-Device C++ Builder Console project, Save all unit and project files into a folder.

2. Let’s do as simple as possible. Clear all codes, add these library includes.

3. Now let’s create our own text_mandelbrot(…) function to draw a Mandelbrot set in text form as a console.

As given in here we defined two complex numbers

We loop in row and column as x and y coordinates, and we calculate height of this function with complex numbers related with these row and column,

4. Finally we need to define our main function to run our text_mandelbrot(…) function.

5. Hit F9 to run your codes or run your code from Run button.

That’s all. This simple code compatible with most of C++ compilers, you may need few changes in some compilers. You can improve this code by drawing a part of this function (like zooming to a portion of it). Or you can use Bitmaps and directly draw it with full details. Don’t worry about calculations and speed about to draw these kind of functions in math. Because C++ is faster to calculate and draw these things. You can also use parallel programming methods to use all of your CPU and GPU cores draw anything multiple times faster.

Full Lines of VCL Console Application in C++ Builder should be like this;

And the result will be like this;


Oh hi there 👋
It’s nice to meet you.

Sign up to receive awesome C++ content in your inbox, every day.

We don’t spam! Read our privacy policy for more info.

About author

33+ years of coding with more than 30+ programming languages, mostly C++ on Windows, Android, Mac-OS, iOS, Linux and some other operating systems. Dr. Yilmaz Yoru was born in 1974, Eskisehir-Turkey. He graduated from the department of Mechanical Engineering of Eskisehir Osmangazi University in 1997. One year later he started to work in the same university as an assistant. He received his MSc and PhD degrees from the same department of the same university. He has married and he is a father of a son. Some of his interests are Programming, Thermodynamics, Fluid Mechanics and Artificial Intelligence. He also likes the graphical 2D & 3D design and high-end innovations.
Related posts
CC++Introduction to C++Learn C++

Who Wrote The C Programming Language?

CC++Introduction to C++Language FeatureLearn C++

Is C A High Level Programming Language?

CC++Introduction to C++Learn C++

How To Run A C Program in Command Prompt

CC++C++17Learn C++

How To Compile And Run A C Program