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

Friday, August 5, 2011

Make interesting pyramid shape with C

In this i will show you way to make a interesting pyramid shape by using C programming language. 
The c code is given bellow.I use nested loop to create this.
#include<stdio.h>
int main(void)
{
    int i,j,l;
    int k=1;
    for(i=1;i<=9;i++)
    {
    for(j=1;j<=i;j++)
    printf("%d ",k%10);
    if(j>=i)
    printf("\n"),k++;

    }

}