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
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
#include<stdio.h> int main() { int n, c, k, space; printf("Enter number of rows\n"); scanf("%d",&n); if (n >23) { printf ("number too high\n"); } space = n; for ( k = 1 ; k <= n ; k++ ) { for ( c = 1 ; c < space ; c++ ) printf(" "); space--; for( c = 1 ; c <= k ; c++ ) printf("#"); printf("\n"); } return 0; }