Tuesday, January 4, 2011

Inverted Triangles Pattern in C

coding:

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,n,m;
char a='*';
clrscr();
printf("Enter the Number: ");
scanf("%d",&n);
for(i=n;i>=1;i--)
{
for(j=1;j<=n-i;j++)

printf(" ");
for(j=1;j<=i;j++)

printf("%4c",a);
printf("\n");
}

for(i=2;i<=n;i++)

{
for(j=1;j<=n-i;j++)

printf(" ");
for(j=1;j<=i;j++)

printf("%4c",a);
printf("\n");
}
getch();
}


Output:

No comments: