Prerequisite: How to include graphics.h?, graphics.h
The task is to draw an ellipse that is intersected by a straight line passing through the center of the ellipse diagonally. And then color both segments with different colors.
Approach: To run the program we need to include the following header file:
We will create the desired ellipse with the help of the following functions:
- void ellipse(int x, int y, int from_angle, int to_angle, int x_rad, int y_rad): A function from graphics.h header file is responsible for creating ellipse on the screen.
- void line(int x1, int y1, int x2, int y2): A function from graphics.h header file which draw a line.
- void floodfill(int x, int y, int border_color): A function from graphics.h header file is responsible function is used to fill an enclosed area. Current fill pattern and fill color is used to fill the area.
Below is the implementation of the above approach: