mardi 3 mars 2020

C input 2 time and examine previous value

what is the problem of the code here:

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

void main() {
    setvbuf(stdout, NULL, _IONBF, 0);
    setvbuf(stderr, NULL, _IONBF, 0);

    int a = 5, b = 8;
    int inputs;
    printf("Guess value of a: \n");
    scanf("%d\n", &inputs);
    while (inputs > 0){
        if(inputs == a){
                printf("Correct!\n");
                break;
            }
            else{
                printf("Wrong!Try again!\n");
                scanf("%d\n", &inputs);
            }
    }

}

I just trying the if stuff but the program take 2 input first, and examine the value of the previous one.

Aucun commentaire:

Enregistrer un commentaire