+ 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

30th Jul 2020, 3:13 PM
Sharath Kumar
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 )
1st Aug 2020, 5:13 AM
Bot
Bot - avatar
+ 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
30th Jul 2020, 5:06 PM
â€ŽÙŠÙˆŰłÙ ŰłŰčۯ‎
â€ŽÙŠÙˆŰłÙ ŰłŰčۯ‎ - avatar
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
30th Jul 2020, 3:17 PM
Ipang
0
Ya I have shared my code see.
30th Jul 2020, 3:31 PM
Sharath Kumar
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.
30th Jul 2020, 3:56 PM
Ipang
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.
30th Jul 2020, 4:06 PM
Sharath Kumar