Write a C program that reads the value of an integer variable x and the value of a character variable color from the keyboard ('R’ for red, G' for green, B' for blue), and decides if the color is correct according to the given rang e. Red Green Blue + X 10 20 30 If x is between 0 and 10, color must be red If x is between 11 and 20, color must be green If x is between 21 and 30, color must be blue

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter4: Selection Structures
Section4.2: The If-else Statement
Problem 3E
icon
Related questions
Question

The code should be written and worked out in C programming language only.

Please do not write in other programming languages because code sources written in other languages will not work for me.

Only use #include <stdio.h> as a header.

Please do not use #include <stdlib.h> or other headers.

Write a C program that reads the value of an integer variable x and the value of a character
variable color from the keyboard (R' for red, 'G’ for green, B’ for blue), and decides if the
color is correct according to the given range.
Red
Green
Blue
10
20
30
If x is between 0 and 10, color must be red
If x is between 11 and 20, color must be green
If x is between 21 and 30, color must be blue
If the color is correct according to the given range, print "correct color";
otherwise print “wrong color"
If x is out of this range, print “out of range"
Transcribed Image Text:Write a C program that reads the value of an integer variable x and the value of a character variable color from the keyboard (R' for red, 'G’ for green, B’ for blue), and decides if the color is correct according to the given range. Red Green Blue 10 20 30 If x is between 0 and 10, color must be red If x is between 11 and 20, color must be green If x is between 21 and 30, color must be blue If the color is correct according to the given range, print "correct color"; otherwise print “wrong color" If x is out of this range, print “out of range"
Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
ADT and Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr