+ 1
How to build a pyramid?
How to the pyramid with # using c language? # ## ### #### ##### ###### ####### ######## This is what đI wanted to do using C . I got thisđ # ## ### #### ##### ###### ####### ######## What I want to do to get required format of #es . https://code.sololearn.com/c4R34DYSlAbh/?ref=app
6 Respostas
+ 3
Corrected code:
#include <stdio.h>
int main() {
int n;
do
{
scanf("%i",&n);
}
while (n<1||n>8);
for(int i=0;i<n;i++)
{
for(int k=0;k<n-i;k++)
{
printf (" ");
}
for(int j=0;j<=i;j++)
{
printf ("#");
}
printf ("\n");
}
return 0;
}
explanation:
you need to use double for loop, one for the spaces and other for the #'s (other than the outer for loop to print the \n for each columns )
+ 1
I'm not good at C language.
But generaly:
You just need to align it.
Hint
Think of it as twin pyramids, one's bottom in the top of the other.Like this
(*)refers to space
*******#
******##
*****###
****####
***#####
**######
*#######
Note: spaces decrease as hashes increase.
Now it's time to start yor creation inđ your own way.
Hope this helps.đ
iam sorry if i do not demostrate it well
0
I think all there is left for you to do is to figure out how to insert enough spaces before the # to push the # to the right.
If you don't share your code people can't help you. They need to analyse your code before they can suggest anything. Follow the below guide to share your code đ
https://www.sololearn.com/post/75089/?ref=app
0
Ya I have shared my code see.
0
Header file <cs50.h> is not part of standard, it may or may not be available.
I don't see definition of `get_int` function, I'm guessing it's in the <cs50.h>.
Purpose of while-loop on line 9 is unclear.
0
Oo that for getting input between 1 and 8 only. purpose of 'get_int' is to prompt for users input and input should be in between 1 and 8.