0

I have the following code for C

int get_pyramid_steps(string prompt);

//Ask height
int main(void)
{
    int i = get_int("pick a number: ");
        printf("you said %i\n", i);
}
//if i < 1 or i > 8

int get_pyramid_steps(string prompt) 
{
    int j;
    do
    {
       j = get_int("%s", prompt);
    }
    while (j > 8 || j < 2);
    return j;

}

The end goal is to make the user continually "say pick a number" for any >2 and < 8 but the following seems to be ignored

int get_pyramid_steps(string prompt) 
    {
        int j;
        do
        {
           j = get_int("%s", prompt);
        }
        while (j > 8 || j < 2);
        return j;

    }
1
  • I suspected it was the order of operations but am not having luck with that.
    – Steve Rose
    Commented Jan 18, 2019 at 4:51

1 Answer 1

1

The problem is that the function get_pyramid_steps is never called by anything in main. It might as well not be there.

If this answers your question, please click on the check mark. Let's keep up on forum maintenance. ;-)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .