69 668
Assignments Done
99,4%
Successfully Done
In February 2019

Answer to Question #54474 in C for rajashree g.s

Question #54474
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.
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
}

return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!