declare two variables x and y.assign values to these variables.Number x should be printed only if it is less than 2000 or greater than 3000 and number y should be printed only if it is between 100 and 500. please explain the logic sir.
1
Expert's answer
2015-09-07T01:26:57-0400
Solution int main() { int x, y; // You declare variables x and y scanf_s("%d", &x); // You assign value for x scanf_s("\n%d", &y); // You assign value for y
if (x < 2000 || x > 3000) { // Number x should be printed only if it is less than 2000 or greater than 3000 printf("\n%d", x); // You print variable x }
if (y > 100 && y < 500) { // Number y should be printed only if it is between 100 and 500 (variable y must be greater // than 100 and less than 500) printf("\n%d", y); // You print variable x }
Comments
Leave a comment