Friday, 24 July 2015

C Program - For Loop 10

C Program - For Loop 10 

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

Output :- 


Enter the number of rows ;-





No comments:

Post a Comment