Pattern 6
Write A Prog. to print following Pattern
*
**
***
****
*****
****
***
**
*
#include<conio.h>
#include<stdio.h>
void main()
{
int n=0,i,j;
clrscr();
printf("Enter N:");
scanf("%d",&n);
printf("\n\n");
for(i=0;i<n;i++)
{
for(j=1;j<n-i;j++)
{
printf(" ");
}
for(j=0;j<=i;j++)
{
printf("*");
}
printf("\n");
}
for(i=n-1;i>=1;i--)
{
for(j=i;j<n;j++)
{
printf(" ");
}
for(j=1;j<=i;j++)
{
printf("*");
}
printf("\n");
}
getch();
}
O/P:
Write A Prog. to print following Pattern
*
**
***
****
*****
****
***
**
*
#include<conio.h>
#include<stdio.h>
void main()
{
int n=0,i,j;
clrscr();
printf("Enter N:");
scanf("%d",&n);
printf("\n\n");
for(i=0;i<n;i++)
{
for(j=1;j<n-i;j++)
{
printf(" ");
}
for(j=0;j<=i;j++)
{
printf("*");
}
printf("\n");
}
for(i=n-1;i>=1;i--)
{
for(j=i;j<n;j++)
{
printf(" ");
}
for(j=1;j<=i;j++)
{
printf("*");
}
printf("\n");
}
getch();
}
O/P:
No comments:
Post a Comment