Click the Follow Button

c ; how to use "and" operator in if-else

 

// if - else func
#include <stdio.h>

int main()
{
    char x;
    printf("Agree or not?\n");
    scanf("%c", &x);
// use the word and / or
    if (x == 'y' || x == 'Y') //here 2 vertical bars means 'and' oparator
    {
        printf("OK. Agreed");
    }
    else if (x == 'n' || x == 'N')
    {
        printf("Not agreed.");
    }
}

Comments

Popular Posts

TIC - TAC - TOE

Prime and not prime number

do_while loop is to do something again and again