In c language, 0 < num1 < 45
cannot be used. You must use 0 < num1 && num1 < 45
using the logical and operator (&&&&).
The && operator is an operator that returns true only when both left and right sides are true. Therefore, 0 < num1 &&& num1 < 45
is true only when num1 is greater than 0 and num1 is less than 45.
Please refer to the code and results below.
#include <stdio.h>
int main()
{
int num1;
scanf_s("%d", &num1);
if (0 < num1 && num1 < 45)
printf("a");
else if (90 < num1 && num1 < 160)
printf("b");
else
printf ("None";
return 0;
}
© 2024 OneMinuteCode. All rights reserved.