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
Post a Comment