i have been trying to solve this problem :
:) mario.c exists
:) mario.c compiles
:) rejects a height of -1
:) handles a height of 0 correctly
:) handles a height of 1 correctly
:( handles a height of 2 correctly
\ expected output, but not "###\n"
:( handles a height of 23 correctly
\ expected output, but not "#############\n"
:( rejects a height of 24, and then accepts a height of 2
\ expected output, but not "###\n"
:) rejects a non-numeric height of "foo"
:) rejects a non-numeric height of ""
Code:
#include <stdio.h>
#include <cs50.h>
int main()
{
//The first thing i did, was declaring my variables
int n; //int n is the choosen number (that you choose)
int h; //is the height
int spce; //are the spaces
int hsh; //are the #
do
{
printf("Please choose a number from 0-23: ");//here i ask the "user" to choose the number
n=GetInt();
if (n==0)
{
return 0; // Here is a loop that i made if the "User" chooses 0 so it asks again
}
} while (n<0 || n>23);
for (h=0; h<n ; h++) //if the height is less than the number choosen (n) it adds one to the height
{
for (spce=0; spce < n-spce-1; spce++){}
}
for (hsh=0; hsh<spce+2; hsh++)
{
printf("#");
}
printf("\n");
return 0;
}