Skip to main content

I have a program which it is supposed to print Mario-like towers on each side corresponding to the amount you input. Everything seems to work but when I try to check the code it gives the error ":( rejects a height of 9, and then accepts a height of 2 expected program to reject input, but it did not" I tried putting a height of 9 and height of 2, they both should work but I still am receiving the error

#include <stdio.h>
int main(void)
{
    int num = 1;
    int num1 = 1;
    int towers;
    do{
        towers = get_int("Height ");
    }
    while(towers<1towers < 1);
    int figure = towers;
    for(int i = 1; i<=towers;i <= towers; i++) { // repeats for length, should work
    for(int e = 0; e<figuree < figure-1; e++) { // prints .. before the # amount of length-1
        printf(" ");
    }
    figure--;
        for(int x = 0; x<num;x < num; x++) { // prints the #
            printf("#");
        }
        num++;
        printf("  ");
        for(int y = 0; y<num1;y < num1; y++) { // prints the #
            printf("#");
        }
        num1++;
        printf("\n");

    }
    return 0;
    }

I have a program which it is supposed to print Mario-like towers on each side corresponding to the amount you input. Everything seems to work but when I try to check the code it gives the error ":( rejects a height of 9, and then accepts a height of 2 expected program to reject input, but it did not" I tried putting a height of 9 and height of 2, they both should work but I still am receiving the error

#include <stdio.h>
int main(void)
{
    int num = 1;
    int num1 = 1;
    int towers;
    do{
        towers = get_int("Height ");
    }
    while(towers<1);
    int figure = towers;
    for(int i = 1; i<=towers; i++) { // repeats for length, should work
    for(int e = 0; e<figure-1; e++) { // prints .. before the # amount of length-1
        printf(" ");
    }
    figure--;
        for(int x = 0; x<num; x++) { // prints the #
            printf("#");
        }
        num++;
        printf("  ");
        for(int y = 0; y<num1; y++) { // prints the #
            printf("#");
        }
        num1++;
        printf("\n");

    }
    return 0;
    }

I have a program which it is supposed to print Mario-like towers on each side corresponding to the amount you input. Everything seems to work but when I try to check the code it gives the error ":( rejects a height of 9, and then accepts a height of 2 expected program to reject input, but it did not" I tried putting a height of 9 and height of 2, they both should work but I still am receiving the error

#include <stdio.h>
int main(void)
{
    int num = 1;
    int num1 = 1;
    int towers;
    do{
        towers = get_int("Height ");
    }
    while(towers < 1);
    int figure = towers;
    for(int i = 1; i <= towers; i++) { // repeats for length, should work
    for(int e = 0; e < figure-1; e++) { // prints .. before the # amount of length-1
        printf(" ");
    }
    figure--;
        for(int x = 0; x < num; x++) { // prints the #
            printf("#");
        }
        num++;
        printf("  ");
        for(int y = 0; y < num1; y++) { // prints the #
            printf("#");
        }
        num1++;
        printf("\n");

    }
    return 0;
    }
Source Link

In my CS50 mario program I'm getting an error which shouldn't be happening (C)

I have a program which it is supposed to print Mario-like towers on each side corresponding to the amount you input. Everything seems to work but when I try to check the code it gives the error ":( rejects a height of 9, and then accepts a height of 2 expected program to reject input, but it did not" I tried putting a height of 9 and height of 2, they both should work but I still am receiving the error

#include <stdio.h>
int main(void)
{
    int num = 1;
    int num1 = 1;
    int towers;
    do{
        towers = get_int("Height ");
    }
    while(towers<1);
    int figure = towers;
    for(int i = 1; i<=towers; i++) { // repeats for length, should work
    for(int e = 0; e<figure-1; e++) { // prints .. before the # amount of length-1
        printf(" ");
    }
    figure--;
        for(int x = 0; x<num; x++) { // prints the #
            printf("#");
        }
        num++;
        printf("  ");
        for(int y = 0; y<num1; y++) { // prints the #
            printf("#");
        }
        num1++;
        printf("\n");

    }
    return 0;
    }