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: 170881

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].

 
Akash Mathwani from India Comment on: Dec 16
HERE IS THE CODE BY USING WHILE



#include <stdio.h>
#include <stdlib.h>

int main()
{
int i=0;
int n;
int z=0;
int space=0;

printf("enter the value of n\n");
scanf(" %d",&n);


while(i<=n-1){

while (i<=n-1){
printf("* ");
i++;
}
i=z+1;
z++;
printf("\n");
space=0;
while(space<=i-1){
printf(" ");
space++;
}

}
return 0;
}

Harini Swetha from India Comment on: Oct 11
pls give a code to print the two sides of the letter V SEPARATELY...


LIKE,

*
*
*
*
*
*

Harini Swetha from India Comment on: Oct 11
how do i print this pattern? pls post it...
*
*
*
*

View All Comments