Code Competitions

Coding competition

Monday, 13 May 2013

program to draw pattern

#include<stdio.h>
#include<conio.h>
void main()
{
    int i,j,n,l,k;
    clrscr();
    printf("enter the value of n");
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        for(j=i;j<n;j++)
        {
            printf("  ");
        }
        for(k=i;k<=(2*i-1);k++)
        {
            printf("%d ",k);
        }
        for(l=2*i-2;l>=i;l--)
        {
            printf("%d ",l);
        }
        printf("\n");
    }
    getche();
}

No comments:

Post a Comment