Q:

C Programs For Print A Pyramid Pattern Using Star (*)

belongs to collection: Patterns Basic C Programs

0

C Programs For Print A Pyramid Pattern Using Star (*)

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include<conio.h>
#include<stdio.h>
main()
{
int len,i,j;
int fp,lp;

    printf("enter no. of lines you want\n");
    scanf("%d",&len);
    printf("\n");

    fp = lp = len-1;
   
    for(i=0; i<len; i++)
    {
        for(j=0; j<2*len-1; j++)
        {
            if(j>=fp && j<=lp)
                printf("*",j);
            else
                printf(" ");
        }
        fp-- ,lp++;

        printf("\n");
    }

}

 

Output:

enter no. of lines you want

10

         *         

        ***        

       *****       

      *******      

     *********     

    ***********    

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

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

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

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

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
C Program For Print A Left Pascal Triangle Using N... >>