Can be help me? I can't find the error. Please.

Rafaela Morato preguntado 3 years ago

int r;


    while(r !=2002){
        printf("Senha Invalida\n");

        if (r == 2002){
            printf("Acesso Permitido\n");

Recuerda no enviar soluciones. Tu mensaje puede ser revisado por nuestros moderadores.

  • Pedro Feitosa respondido 10 months ago

    Your algorithm nevers stops because you read the 'r' just one time. So if r != 2002, that 'while' will be forever in loop. The problems stopswhen the password is correct.

  • Kitkat respondido 2 years ago

    With that kind of "while" you are only readind 1 input, so is basically not a real loop. You need to read many inputs until one of them is the correct password (senha). So you do it like this: while( scanf("%d", &r)) { code code code

  • Wellerson Salvatore respondido 3 years ago

    change your while:


    and after "printf" on line 9 put "break".