Struggling with some basic code - Programmers Heaven

Howdy, Stranger!

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


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.