Sunday, January 1, 2012

Print following pattern. * * * * * * * * * * in 'C'


   *
  * *
 * * *
* * * *
Example



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


}
printf("\n");
}
getch();
}
/*=====================================================================
OUTPUT
Enter the value of n:4
       *
      * *
     * * *
    * * * *
*/



No comments:

Post a Comment