programming-examples/c/Pattern_Programs/P_star..c

53 lines
887 B
C
Raw Normal View History

2019-11-15 12:59:38 +01:00
/* Pattern Problem
*
* *
* * *
* *
*
*/
#include <stdio.h>
#include <conio.h>
void main()
{
int i, j ;
clrscr() ;
printf("Required pattern is as follows: \n") ;
for(i=1 ; i<=3 ; i++)
{
/* Managing spaces */
for(j=1 ; j<=3-i ; j++)
printf(" ") ;
/* Printing from left to Centre */
for(j=1 ; j<=i ; j++)
printf("* ") ;
printf("\n") ;
}
for(i=3-1 ; i>=1 ; i--)
{
/* Managing spaces */
for(j=3-i ; j>=1 ; j--)
printf(" ") ;
/* Printing from left to Centre */
for(j=1 ; j<=i ; j++)
printf("* ") ;
printf("\n") ;
}
getch();
}
/*
Output:
Required pattern is as follows:
*
* *
* * *
* *
*
*/