1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Zolol [24]
2 years ago
9

Remove gray from RGB Summary: Given integer values for red, green, and blue, subtract the gray from each value. Computers repres

ent color by combining the sub-colors red, green, and blue (rgb). Each sub-color's value can range from 0 to 255. Thus (255, 0, 0) is bright red, (130, 0, 130) is a medium purple, (0, 0, 0) is black, (255, 255, 255) is white, and (40, 40, 40) is a dark gray. (130, 50, 130) is a faded purple, due to the (50, 50, 50) gray part. (In other words, equal amounts of red, green, blue yield gray). Given values for red, green, and blue, remove the gray part.

Computers and Technology
1 answer:
sergejj [24]2 years ago
5 0

Answer:  

Here is the C++ program:  

#include <iostream>   //to use input output functions    

using namespace std;   //to identify objects cin cout    

int main() {   //start of main method    

int red,green,blue,smallest;   //declare variables to store integer values of red,green, blue and to store the smallest value    

cout<<"Enter value for red: ";  //prompts user to enter value for red    

cin>>red;  //reads value for red from user    

cout<<"Enter value for green: ";  //prompts user to enter value for green  

cin>>green; //reads value for green from user    

cout<<"Enter value for blue: "; //prompts user to enter value for blue    

cin>>blue;   //reads value for blue from user    

//computes the smallest value  

if(red<green && red<blue) //if red value is less than green and blue values    

smallest=red;   //red is the smallest so assign value of red to smallest    

else if(green<blue)   //if green value is less than blue value    

smallest=green; //green is the smallest so assign value of green to smallest  

else //this means blue is the smallest    

smallest=blue;  //assign value of blue to smallest    

//removes gray part by subtracting smallest from rgb  

red=red-smallest; //subtract smallest from red    

green=green-smallest; //subtract smallest from green    

blue=blue-smallest; //subtract smallest from blue    

cout<<"red after removing gray part: "<<red<<endl;  //displays amount of red after removing gray    

cout<<"green after removing gray part: "<<green<<endl; //displays amount of green after removing gray  

cout<<"blue after removing gray part: "<<blue<<endl;  } //displays amount of blue after removing gray  

Explanation:  

I will explain the program using an example.    

Lets say user enter 130 as value for red, 50 for green and 130 for blue. So  

red = 130    

green = 50

blue = 130  

First if condition if(red<green && red<blue)   checks if value of red is less than green and blue. Since red=130 so this condition evaluate to false and the program moves to the else if part else if(green<blue) which checks if green is less than blue. This condition evaluates to true as green=50 and blue = 130 so green is less than blue. Hence the body of this else if executes which has the statement: smallest=green;  so the smallest it set to green value.    

smallest = 50    

Now the statement: red=red-smallest; becomes:    

red = 130 - 50    

red = 80    

the statement: green=green-smallest;  becomes:    

green = 50 - 50    

green = 0    

the statement: blue=blue-smallest; becomes:    

blue = 130 - 50    

blue = 80    

So the output of the entire program is:    

red after removing gray part: 80                                                                                                 green after removing gray part: 0                                                                                                blue after removing gray part: 80    

The screenshot of the program along with its output is attached.

You might be interested in
If a wire has insulation that allows it to operate in a temperature of up to 194 degrees Fahrenheit, what temperature will the w
zzz [600]
(194°F-32)×5/9
= 90°C
therefore the answer is 90degrees Celcius
6 0
3 years ago
Consider the following methods:
il63 [147K]
<span>2. basketball This is a classic case of overloading in C++. You have 2 functions, both named "printSport", but one of the functions receives an input of type double, and the other receives an input of type int. The specified method call passes a parameter of type int, so the version of printSport is called that receives a parameter of type int. And that version of printSport only prints the word "basketball". The other version of printSport is never called at all.</span>
4 0
3 years ago
2. The part of the computer that provides access to the Internet is the A. monitor. B. keyboard. C. system unit. D. modem.
allochka39001 [22]
The modem provides access to the internet.
4 0
3 years ago
Read 2 more answers
Please help!! will fan and medal
levacccp [35]
So here are the answers that would best complete the given statements above.
1. <span>The standard resolution for graphics on the Web is 72 dpi.
2. </span> The larger the <span>resolution, the larger the file size.
3. </span>An Inline <span>image is an image that appears on a Web page.
4. File </span><span>size, download times, and the number of colors are factors that will help you decide which graphic format you should use.
5. </span> Adobe Photoshop <span>is an image editing program.
6. The IMG tag </span><span>s used to bring an image into a Web site. 
7. The PNG </span><span>format was the most recently developed popular graphic format. </span>
7 0
3 years ago
Read 2 more answers
Which of the following is true about algorithms?
Artist 52 [7]

Answer:

C

Explanation:

A is false because they usually <em>are</em> used to solve problems

B is false because many different algorithms can solve a problem!

C - true

D is false because humans can write an algorithm.  

8 0
3 years ago
Other questions:
  • Which step of creating a financial budget involves listing the payroll, rental, and utility costs?
    10·2 answers
  • Computers spend most of their time in loops, so multiple loop itera- tions are great places to speculatively find more work to k
    10·1 answer
  • How can i do a back up on one computer and save it to the hard drive in another computer without it being seen by others on the
    9·1 answer
  • ________ computers are specially designed computer chips that reside inside other devices, such as a car. Select one: A. Tablet
    11·2 answers
  • You are to create a program using Python that asks the user for a nonnegative number, then computes the mean and variance using
    15·1 answer
  • Reggie has hired you to design a home network. The home network will share a printer but will mainly be used to stream movies to
    7·1 answer
  • A band wants to know what their most popular CD is so that they can have more copies made to sell. Which statistical measurement
    11·2 answers
  • Explain why there are fundamental ideas of software engineering that apply to all types of software systems.
    7·1 answer
  • Question #4
    8·1 answer
  • Which type of GUI control would be best to use if you wanted the user to select one date from a list of three possible dates to
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!