# 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.

Expert's answer

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;

}

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 orderand get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

## Comments

## Leave a comment