Tuesday 24 July 2012

Pyramid | Star pattern | for loop | source code

Pyramid | Star pattern | for loop  | source code 
* To print Pyramid Pattern shown below


        *
      * * *
    * * * * *
  * * * * * * *
* * * * * * * * *

*/

#include<stdio.h>
int main()
{
int i,j,n;

printf("Enter no. of lines: ");
scanf( "%d",&n);


//for loop for number of lines
for(i=1;i<=n;i++)
{
//for loop for spaces
for(j=1;j<=n-i;j++)
{
printf(" ");
} //for loop for stars in first half
for(j=1;j<=i;j++)
{
printf("* ");
} //for loop for stars in second half
for(j=1;j<i;j++)
{
printf("* ");
} printf("\n");
}
return 0;
}
Share This
Previous Post
Next Post

FYJC XI standard online admisson Process and declaraton of Merit list . Cut off List For prevous year also . 10 Th Results onlne declaraton Maharashtra Region .

0 comments: