Monday, August 22, 2011

Make heart shape using C !

The code given bellow will make a shape of heart. Hope u will like it.
#include<stdio.h>
#include<conio.h>
int main(void)
{
   clrscr();
   int i,j,k;
   textbackground(WHITE);
   for(i=0,k=11;i<=90;i+=10,k+=10)
    {
     printf("\r\t\t\t");
     for(j=i;j<k;j++)
    if((j==13||j==17)||(j>=22&&j<=24)||(j>=26&&j<=28)||(j>=31 && j<=39)||(j>=41&&j<=49)||(j>=52&&j<=58)||(j>=63&&j<=67)||(j>=74&&j<=76)||(j==85))
    {
    textcolor(RED);
    cprintf("*");
    }
    else
    {
    textcolor(GREEN);
    cprintf(".");
    }
     cprintf("\n");
    }
   printf("\r\t\t    ");
    cprintf("Happy valentine day\n");
getch();
}
Screenshot of the output !
Add caption

7 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. // THIS WILL WORK BETTER
    #include
    #include
    #include
    #include
    void main()
    {
    int gd=DETECT,gm,i,j,k;
    int h1[200]={320,200,300,170,285,160,267,158,250,160,230,170,220,185,220,200,320,350};
    int h2[200]={320,200,340,170,355,160,373,158,390,160,410,170,420,185,420,200,320,350};
    initgraph(&gd,&gm,"C:\\TC\\bgi");
    setcolor(RED);
    setbkcolor(WHITE);
    setfillstyle(SOLID_FILL,RED);
    drawpoly(9,h1);
    drawpoly(9,h2);
    floodfill(320,220,RED);
    getch();
    }

    ReplyDelete
  3. plzzz add stdio.h conio.h and graphics.h too

    ReplyDelete
    Replies
    1. THERE ARE 4 "# INCLUDE"
      1'S FOR STDIO.H;
      2NDS FOR CONIO.H;
      3RDS FOR GRAPHICS.H;
      AND WHATS THE SIGN FOR THE 4TH?/?

      Delete