C code to draw pyramid using stars | C code champ

C code to draw pyramid using stars | C code champ

3176
18
SHARE

C code to draw pyramid using stars : Friends today we will learn how to draw a cool pyramid using C programming. Drawing a pyramid is not a big deal but taking number of lines as variable input from user makes it bit tricky. But using two simple for loops we can easily draw a pyramid using stars. Just we need to keep in mind that first for loop draws spaces and next internal for loop prints stars.

Frankly speaking, drawing pyramid is something more like Pascal triangle, just replaced with stars :D . So in our next program we gonna extend our logic to draw a pascals triangle which is heavily used in binomial theorems in . Let us see how to write a to draw pyramid using stars.

C code to draw pyramid using stars :

#include<stdio.h>
#include<conio.h>

int main()
{
   int i, n, c;

   printf("Enter the number of rows wou want in your pyramid : ");
   scanf("%d",&n);
   printf("\n\n\n");
   for ( i = 0 ; i < n ; i++ )
   {
      printf("\t\t");
      for ( c = 0 ; c <= ( n - i - 2 ) ; c++ )
         printf(" ");

      for( c = 0 ; c <= i ; c++ )
         printf("* ");

      printf("\n");
   }
   getch();
   return 0;
}

We hope you all have enjoyed the above . If you have any issues with above code or logic ask us in form of comments.

18 COMMENTS

  1. obviously like your web site but you have to test the spelling on quite a few of your posts. Several of them are rife with spelling issues and I to find it very bothersome to inform the truth then again I will definitely come again again.

  2. Excellent post at C code to draw pyramid using stars | C code champ. I was checking continuously this blog and I am impressed! Extremely helpful information specifically the last part :) I care for such information a lot. I was seeking this certain info for a very long time. Thank you and best of luck.

  3. Wow, wonderful blog layout! How long have you been blogging for? you made blogging look easy. The overall look of your site is wonderful, let alone the content!. Thanks For Your article about C code to draw pyramid using stars | C code champ .

  4. Thanks for sharing excellent informations. Your site is so cool. I am impressed by the details that you have on this web site. It reveals how nicely you perceive this subject. Bookmarked this website page, will come back for extra articles. You, my pal, ROCK! I found simply the info I already searched all over the place and simply could not come across. What a perfect site.

  5. Wow, wonderful blog layout! How long have you been blogging for? you made blogging look easy. The overall look of your site is fantastic, let alone the content!. Thanks For Your article about C code to draw pyramid using stars | C code champ .

  6. Its like you read my mind! You seem to know a lot about this, like you wrote the book in it or something. I think that you could do with some pics to drive the message home a little bit, but instead of that, this is excellent blog. A great read. I will certainly be back.
    [url=http://blog.wedding-travel.com/rjlistanhei/]Avice Laliberte’s store[/url]
    Avice Laliberte’s store

  7. Wow, incredible blog layout! How long have you been blogging for? you make blogging look easy. The overall look of your site is excellent, let alone the content!. Thanks For Your article about C code to draw pyramid using stars | C code champ .

  8. Wow, fantastic blog layout! How long have you been blogging for? you made blogging look easy. The overall look of your web site is magnificent, let alone the content!. Thanks For Your article about C code to draw pyramid using stars | C code champ .

  9. Just desire to say your article is as surprising. The clarity in your post is just cool and i could assume you are an expert on this subject. Well with your permission allow me to grab your RSS feed to keep up to date with forthcoming post. Thanks a million and please keep up the gratifying work.

  10. May I simply say what a relief to uncover somebody
    that actually understands what they’re discussing over the internet.
    You actually understand how to bring a problem to
    light and make it important. A lot more people should
    read this and understand this side of your story. It’s surprising you aren’t more
    popular given that you surely have the gift.

  11. There is anecdotal proof putting on a bodice can be addictive to those individuals with a fanatical character,” says Lemon.

  12. At the very same time, midsection training corsets
    will raise sweating on the torso and also will cause even more fat lost.

  13. Thanks for sharing this awesome post. It helps in understanding the concept of loops in C. It would be better if you can fix the alighnment of this program. Anyways … nice post :).

LEAVE A REPLY