Draw a cake



One can draw so many objects in c-graphics like cycle,car,flower etc.etc.Here we are going to draw a cake by using some simple functions of c-graphics.The code to draw a cake in c-grahics is given below:

#include<stdio.h>

#include<conio.h>

#include<graphics.h>

void main()

{

int gd=DETECT,gm;

initgraph(&gd,&gm,"");

ellipse(300,200,0,360,50,15);

line(250,200,250,235);

line(350,200,350,235);

ellipse(300,235,180,0,50,15);

ellipse(260,222,180,0,10,4);

ellipse(280,224,180,0,10,4);

ellipse(300,224,180,0,10,4);

ellipse(320,224,180,0,10,4);

ellipse(340,222,180,0,10,4);

ellipse(300,250,140,40,65,15);

line(235,250,235,300);

line(365,250,365,300);

ellipse(300,300,180,0,65,15);

ellipse(300,290,180,0,65,15);

ellipse(245,280,180,0,10,4);

ellipse(265,284,180,0,10,4);

ellipse(285,284,180,0,10,4);

ellipse(305,284,180,0,10,4);

ellipse(325,284,180,0,10,4);

ellipse(345,284,180,0,10,4);

ellipse(360,282,180,0,6,4);

ellipse(300,260,180,0,65,15);

ellipse(300,315,140,40,80,15);

line(220,315,220,375);

line(380,315,380,375);

ellipse(300,375,180,0,80,15);

ellipse(300,325,180,0,80,15);

ellipse(300,365,180,0,80,15);

ellipse(230,350,180,0,10,4);

ellipse(250,354,180,0,10,4);

ellipse(270,354,180,0,10,4);

ellipse(290,354,180,0,10,4);

ellipse(310,354,180,0,10,4);

ellipse(330,354,180,0,10,4);

ellipse(350,354,180,0,10,4);

ellipse(370,350,180,0,10,4);

line(280,200,280,170);

line(285,200,285,170);

line(280,200,285,200);

line(280,170,285,170);

line(295,200,295,170);

line(300,200,300,170);

line(295,200,300,200);

line(295,170,300,170);

line(310,200,310,170);

line(315,200,315,170);

line(310,200,315,200);

line(310,170,315,170);

ellipse(281,190,35,60,5,60);

ellipse(285,190,120,145,5,60);

ellipse(283,155,178,5,3,8);

ellipse(296,190,35,60,5,60);

ellipse(300,190,120,145,5,60);

ellipse(298,155,178,5,3,8);

ellipse(311,190,35,60,5,60);

ellipse(315,190,120,145,5,60);

ellipse(313,155,178,5,3,8);

setcolor(RED);

settextstyle(1,HORIZ_DIR,4);

outtextxy(400,250,"CAKE");

getch();

closegraph();

}



The above code is responsible for drawing a cake on your output screen.We are using simple ellipse and line functions for drawing a cake.settextstyle functions sets the text pattern and outtextxy function is used to write text at specified location.You can learn all these function in our tutorial Graphics in C.The output of the above program will be as follows:



Output

c_graphics