c - How to make the pyramid (CS50 Mario Program) formed by this code to be right aligned? -


please me create pyramid height "n" print correctly using hashes , spaces right-aligned. have posted code below. program correctly asks user input, doesn't build pyramid right-aligned. if can fix this, please help.

#include <stdio.h> #include <cs50.h>  int main(void) {     int i=0;     int n=0;          {         printf("height:");         n=getint();     } while (n<0 || n>23);      (i=0; i<n; i++)     {         printf(" ");         (int x=0; x<i+2; x++)         {             printf("#");         }         printf("\n");     }      return 0; } 

inside main loop have:

// instruction printing 1 space // sub loop printing x+1 number of hashes // instruction printing new line 

so each time loops round it's correctly drawing hashes , new line not telling draw more 1 space each time unlike subloop hashes instruction doesn't increase each pass.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -