N
N
Nastyuuuushka2016-07-23 19:09:58
C++ / C#
Nastyuuuushka, 2016-07-23 19:09:58

Why doesn't the && operator work?

What library needs to be included? Without &&with one condition, it works fine, but it does not want to with it.

#include <cs50.h>
#include <stdio.h>
#include <stdlib.h>

int GetPositiveInt();

int main() {
    int p = GetPositiveInt();

    printf("THX 4 THE %d!\n", p);

    return 0;
}

int GetPositiveInt()
{
    int p;

    do {
        printf("ENTER NUM IN THE RANGE: ");
        p = GetInt();
    } while (p <=0 && p >= 23);

    return p;
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan, 2016-07-23
@Nastyuuuushka

Think carefully about what you wrote here:
p <=0 && p >= 23

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question