Example 1: C++ program to draw a wheel using the arc, pieslice, and setcolor function
kw.cpp
#include <graphics.h> int main() { int gd = 0, gm = 9; initgraph(&gd, &gm, NULL); setcolor(1); pieslice(200, 200, 0, 20, 150); setcolor(5); pieslice(200, 200, 40, 60, 150); setcolor(4); pieslice(200, 200, 80, 100, 150); setcolor(14); pieslice(200, 200, 120, 140, 150); setcolor(12); pieslice(200, 200, 160, 180, 150); setcolor(1); pieslice(200, 200, 200, 220, 150); setcolor(5); pieslice(200, 200, 240, 260, 150); setcolor(4); pieslice(200, 200, 280, 300, 150); setcolor(14); pieslice(200, 200, 320, 340, 150); setcolor(15); arc(200, 200, 360, 0, 150); delay(5000); return 0; }
Output
kodingwindow@kw:~$ g++ kw.cpp -lgraph
kodingwindow@kw:~$ ./a.out![]()
Example 2: C++ program to draw a wheel using the arc, pieslice, and setcolor function
kw.cpp
#include <graphics.h> int main() { int gd = 0, gm = 9, x, y; initgraph(&gd, &gm, NULL); setcolor(1); arc(200, 200, 0, 360, 150); for (x = 0; x <= 360; x = x + 15) { delay(500); pieslice(200, 200, x, x + 7, 150); } delay(5000); return 0; }
Output
kodingwindow@kw:~$ g++ kw.cpp -lgraph
kodingwindow@kw:~$ ./a.out![]()
Comments and Reactions
What Next?
C++ program to draw a square using the line function
C++ program to draw a square using the rectangle function
C++ program to draw a 3D square using the bar3d function
Advertisement