Answer to Question #282165 in C for Navpreet

Question #282165

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

1
Expert's answer
2021-12-23T00:29:47-0500
#include <stdio.h>

int main()
{
    int x, y;
    
    printf("Input two integers: ");
    if(scanf("%d %d", &x, &y) != 2)
    {
        printf("Bad input\n");
        return 1;
    }

    if(x < 2000 || 3000 < x)
    {
        printf("x = %d\n", x);
    }

    if(100 < y && y < 500)
    {
        printf("y = %d\n", y);
    }
    
    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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS