vendredi 30 avril 2021

Why is the last condition not executing?

The first two conditions for 100<a<200 and 100<b<200 are executing perfectly but the condition for both to be between 100 and 200 is not working any idea why? My code:

#include<stdio.h>
int main()
{
    int a,b;
    printf("Enter the first integer:");
    scanf("%d",&a);
    printf("Enter the second integer:");
    scanf("%d",&b);
    if (100<=a&&a<=200)
    {printf("The integer %d lies between 100 and 200",a);}
    else if (100<=b&&b<=200)
    {printf("The integer %d lies between 100 and 200",b);}
    else if((100<=a&&a<=200)&&(100<=b&&b<=200))
    {printf("Both of the integers lie between 100 and 200");}
    else
    {printf("The integers does not lie between 100 and 200");}
    return 0;
}

Output: enter image description here

Aucun commentaire:

Enregistrer un commentaire