adsense

Hii, welcome to my site. My name is Om prakash kartik. This blog helps you to learn programming languages concepts.

Draw a bulb in c using graphics

Draw a bulb in c using  graphics

  • Bulb turn Off / On  



#include<stdio.h>
#include<graphics.h>
  int main()
   {
     int gd = DETECT, gm ;
     bool option = true;
     char ch;
     char *op;
     initgraph(&gd,&gm,"");
     while(1)
      {
         if(option == true){
            option = false;
            op ="OFF";
            setfillstyle(1,BLACK);
            circle(300,200,30);
            floodfill(302,202,WHITE);
        }
        else if(option == false){
            option = true;
            op = "ON";
            setfillstyle(1,YELLOW);
            circle(300,200,30);
            floodfill(305,208,15);
        }
        if(ch == 27)
            break;
        outtextxy(290,100,op);
        setfillstyle(1,RED);
        rectangle(284,225,315,250);
        floodfill(286,227,15);
        line(300,230,295,205);
        line(300,230,305,205);
        ch = getch();
        cleardevice();
    }
    return 0;
   }
Output :-










Post a Comment

0 Comments