hey guys i need help here i can't create the exact same pyramid as my friend here is the code
#include <stdio.h>
int main() {
int height;
int a;
int pager;
int spacel;
do {
printf("Height: ");
scanf_s("%d", &height);
} while (!(height > 0) || !(height < 24));
for (a = 0; a < height; a++) {
for (spacel = height - a; spacel > 0; spacel--) {
printf(" ");
}
for (pager = 0; pager < (a + 1); pager++) {
printf("#");
}
printf(" ");
for (pager = 0; pager < (a + 1); pager++) {
printf("#");
}
printf("\n");
}
return 0;
}
and this is my version
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
#include <stdio.h>
int main()
{
int a;
int i;
int space1;
int pager;
printf("Insert the height: ");
scanf_s("%d", &a);
{
if ((!(a > 23) & !(0 > a)))
printf("Enjoy");
else
printf("Invalid (Range: 0-23)");
}
for (i = 0; i < a; i++);
{
for (space1 = a - i; space1 > 0; space1--)
printf(" ");
for (pager = 0; pager < (i + 1); pager++)
printf("#");
printf(" ");
for (pager = 0; pager < (i + 1); pager++)
printf("#");
printf("\n");
}
getchar ();
getchar ();
getchar ();
return (0);
}
|
Last edited on
ohh sorry i'm new to this website, i was trying to change some grammar mistake and wrong used of word and i didn't know it post the edited version