Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » Homework HelpRSS Feeds

Program to print pyramid of stars *

Posted By: Alarice Miller     Category: C Programming     Views: 87428

WRITE A PROGRAM TO GENERATE FOLLOWING FIGURE OF N LINES. INPUT N FROM KEYBOARD.
______*
____* * *
__* * * * *
* * * * * * *
consider space in place of line.

Code for Program to print pyramid of stars * in C Programming

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

    printf("\n Please Give The Value of N:  ");
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n-i;j++)
            printf("  ");
        for(j=1;j<=2*i-1;j++)
            printf(" *");
        printf("\n");
    }

    getch();
}




****************************** OUTPUT *********************************




 Please Give The Value of N:  7


             *
           * * *
         * * * * *
       * * * * * * *
     * * * * * * * * *
   * * * * * * * * * * *
 * * * * * * * * * * * * *
  
Share: 


Didn't find what you were looking for? Find more on Program to print pyramid of stars * Or get search suggestion and latest updates.

Alarice Miller
Alarice Miller author of Program to print pyramid of stars * is from Frankfurt, Germany.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
Pratik Nakrani from India Comment on: Nov 08
*
* *
* * *
8 * * * *

where 8=SPACE Plz give this code..

View All Comments