vendredi 24 juillet 2020

Program prints out declined for all variables entered, but I am trying to make it only print that out when a specific letter is entered e.g.'u'?

I'm new to coding so it could be a simple resolve, please bare with me.

I'm trying to create a program that will print Accepted when a letter of the alphabet it entered, excluding u. When u is entered it prints declined.

#include <stdio.h>

int main(void) {
    char val;

    printf("Enter your letter : \n");
    val = scanf("%c", &val);
    
    if (val == 'u' || (val >= '0' || val <= '9'))
        printf("DECLINED\n");
    else
        print("ACCEPTED\n");

    return (0);
}

Aucun commentaire:

Enregistrer un commentaire