You are not following general if-else block property
if(a==1 && b<=8) // This is independent if 1
{
printf("you");
}
Then this is another if-else either of if or else in this block will get executed independently of what has previously happened
if(a==2 && 5<b && b<=10) // This is independent if-else block 2
{
printf("you");
}
else
printf("me");
For achieving what you want it should be if, else if and else block
if(a==1 && b<=8)
{
printf("you");
}
else if(a==2 && 5<b && b<=10)
{
printf("you");
}
else
printf("me");
1
solved multiple if statements in c for beginners [closed]