pyramid pattern

 How to print pyramid

Here is the code for the printing the pyramid pattern in the c programming language.


code:

//print the pyramid pattern by taking input from the user

#include <stdio.h>

int main()

{

int space = 0;

int star = 0;

int lines = 0;

int user = 0;

int starplus = 0;

printf("Enter the number of lines  :");

scanf("%d", &user);

printf("\n");

starplus = user;

while (user != -1){


for (lines = 1; lines <= user; lines++){

for (space = 1; space < lines; space++)

printf(" ");

for (star = 1; star <= starplus; star++){

printf("* ");

}

starplus--;

printf("\n");

}

printf("Enter the number of lines  :");

scanf("%d", &user);

printf("\n");

starplus = user;

}


getch();

return 0;


}

pattern-pattern-in-c



In this example, three for loop is used with different counters.one is used for first spacing and second is used to print the asterisk, then the third one is used to printing second spaces. 

Comments

  1. Aesome! Thanks alot for providing Screen Hunter. Details you provided here is really efective for me here is mine humble request that kindly permit me to get this Screen Hunter Download or hunter douglas designer screen shades. It will be very useful for me,and i will be very thankful to you.

    ReplyDelete
  2. Aesome! Thanks alot for providing Riyan TV Apk download. Details you provided here is really efective for me here is mine humble request that kindly permit me to get this Riyan TV Apk or Riyan TV Apk. It will be very useful for me,and i will be very thankful to you.

    ReplyDelete

Post a Comment

Popular posts from this blog

Diferrence between flutter and react native

Flutter Widgets

Flutter layout