Check whether first number is between second and third in C
This C code checks if given number is between second and third number also provided as input from the user.
/* Aim: To check whether the first number is in between second and third number. */
#include<stdio.h>
int main()
{
int a,b,c;
printf("\n \n Enter Your First number:");
scanf("%d",&a);
printf("\n \n Enter Your Second number:");
scanf("%d",&b);
printf("\n \n Enter Your Third number:");
scanf("%d",&c);
if (((a<b) && (a>c)) || ((a>b) && (a<c)))
{
printf("\n \n %d is in between %d and %d \n \n",a,b,c);
}
else
{
printf("\n \n %d is not in between %d and %d \n \n",a,b,c);
}
return 0;
}
Output:
Enter Your First number:10
Enter Your Second number:11
Enter Your Third number:12
10 is not in between 11 and 12