Friday, 24 July 2015

C Program - For Loop 13

C Program - For Loop 13 



#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k,n;
clrscr();
printf("\nEnter the number of rows :- ");
scanf("%d",&n);
for(i=0;i<n;i++)
{
for(k=0;k<=i;k++)
{
printf("  ");
}
for(j=1;j<=2*(n-i)-1;j++)
{
printf(" *");
}
printf("\n");
}
for(i=1;i<n;i++)
{
for(k=n;k>i;k--)
{
printf("  ");
}
for(j=1;j<=2*i+1;j++)
{
printf(" *");
}
printf("\n");
}
getch();
}

Output :- 














Back to 'C Language Programs'

No comments:

Post a Comment