How to implement basic feature in C

This code will take the user input and use it to build blocks. Entering a number between 1 and 8 it should print something like this.

###
###
###

I want it to take the integer from the user and instead print the blocks like this. Say the user enters the number 5. Currently you'll get this.

#####
#####
#####
#####
#####

However I want it to do this.

#
##
###
####
#####

Can anyone help me understand how to implement this?

#include <cs50.h>
#include <stdio.h>



int main(void)
{
    int n;
    do
    {
        n = get_int("Size: ");
    }
    while (n < 1 || n > 8);
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            printf("#");
        }
        printf("\n");
    }
}


Read more here: https://stackoverflow.com/questions/64947198/how-to-implement-basic-feature-in-c

Content Attribution

This content was originally published by higherbeing22 at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: