Star Pattern
/*
To print following star(*) pattern
*
* *
* * *
* * * *
* * * * *
*/
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,n,t;
clrscr();
printf("enter the n");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("\n");
for(j=n;j>=i;j--)
{
printf(" ");
}
for(t=1;t<=i;t++)
{
printf("* ",t);
}
}
getch();
}
/*
output :-
-----------
enter the n5
*
* *
* * *
* * * *
* * * * *
*/
To print following star(*) pattern
*
* *
* * *
* * * *
* * * * *
*/
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,n,t;
clrscr();
printf("enter the n");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("\n");
for(j=n;j>=i;j--)
{
printf(" ");
}
for(t=1;t<=i;t++)
{
printf("* ",t);
}
}
getch();
}
/*
output :-
-----------
enter the n5
*
* *
* * *
* * * *
* * * * *
*/
nice post
ReplyDeleteC Program to print pattern