Struggling with some basic code

Hi all,

Im a beginner with any form of coding and im trying to solve a problem but the lightbulb has not switched on just yet...

ive managed to scramble the code below to allow me to do part of what I wanted but im struggling with the data input side.

Basically I want to add something to the code below but im not sure where to put it at present. I would like the user to be prompted for a number (get int possible to use?) between 1-50 which will then return the suitable output (the number inputted would denote the number of rows) but I want to include a loop to ensure that if I dont enter a number between 1-50 it just goes back to the start and asks again.

Apologies if im not making much sense, its a simple problem but im just not seeing where I can put the code or how to exactly construct it.

Any help would be greatly appreciated.

Many Thanks



int main()
int n, c, k, space;

printf("Enter number of rows
if (n >23) {
printf ("number too high

space = n;

for ( k = 1 ; k <= n ; k++ )
for ( c = 1 ; c < space ; c++ )
printf(" ");


for( c = 1 ; c <= k ; c++ )


return 0;


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!