Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cs50.h>
- #include <stdio.h>
- void loop(void);
- int main(void)
- { int s = 7;
- int H, i, L;
- printf("please Enter an integer value :"); //Taking the hight from the user
- scanf("%d", &H);
- if (H > 0 && H <= 8)
- {
- for (i = 1; i <= H; i++) // loops for buliding the pyramid
- {
- for (L = 1; L <= i; L++)
- { s--;
- do
- {
- printf(".");
- s--;
- }
- while(s!=0);
- printf("#");
- }
- printf("\n");
- }
- }
- else if (H <= 0 || H > 8) //if the value isn't right
- {
- do// very important to repeat the error msg in case the user keeps putting a wrong number .
- {
- printf("Error please Enter a correct Value: ");
- scanf("%d", &H);
- }
- while (H <= 0 || H > 8);// the condition to repeat the error msg
- if (H > 0 && H <= 8)
- {
- for (i = 1; i <= H; i++) // the loop for building the pyramid again .
- {
- for (L = 1; L <= i; L++)
- {
- printf("#");
- }
- printf("\n");
- }
- }
- }
- return 0 ;
- }
Advertisement
Add Comment
Please, Sign In to add comment