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++;

    }

}

Sunday, July 31, 2011

Learn array declaretion in programming language C

#include<stdio.h>          //header file
#include<conio.h>          //header file

int main(int i[])          //main function
{
    clrscr();              //clear output screen
    int n,j;
    printf("How many element do you enter?\n");
    scanf("%d",&n);        //collect data numbre
    for(j=0;j<n;j++)       //for loop
    {
    printf("Enter element no %d: ",j+1);
    scanf("%d",&i[j+1]);                 //collect data in the array
    }
    printf("\n\nData you have enterd:\n");
    for(j=0;j<n;j++)        //2nd for loop
    {
    printf("Element no %d: %d\n",j+1,i[j+1]);       //print collected data
    }
    getch();                //show the output screen
}