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]
3 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]3 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
The__ key is used to group or identify a field or record within a table. (you don't need it).
SVEN [57.7K]

Answer:

B.

Explanation:

6 0
3 years ago
Read 2 more answers
What is a computer modem?​
ahrayia [7]

Answer:

A modem modulates and demodulates electrical signals sent through phone lines, coaxial cables, or other types of wiring.

8 0
3 years ago
Show a single view of an object, but show it in a way that makes it look 3-D, as your eye would see it.
Fofino [41]

A square from the front

5 0
3 years ago
Which statement best describes the cut and paste option in a word processor?
tekilochka [14]

B i correct so yea and yea

8 0
3 years ago
Read 2 more answers
The idea generating technique most often used in writing business letter is ?
aivan3 [116]
Hihi!

The correct answer is free writing! Free writing <span>is a prewriting technique in which a person writes continuously for a set period of time without regard to spelling, grammar, or topic! People tend to use it because it produces raw, often unusable material, but helps </span>writers<span> overcome blocks of apathy and self-criticism!</span>

I hope I helped!
-Jailbaitasmr
6 0
3 years ago
Read 2 more answers
Other questions:
  • 1.6.6 Night out for codehs
    6·1 answer
  • About n processes are time-sharing the CPU, each requiring T ms of CPU time to complete. The context switching overhead is S ms.
    12·1 answer
  • Tommy has hired a marketing company to create a billboard advertisement
    11·2 answers
  • When uninstalling software, it is best to delete the folder containing the software?
    11·1 answer
  • Which group on the Home Tab allows you to add shapes to a PowerPoint slide?
    9·2 answers
  • The cold war actually helped in the development of the internet true or false
    8·1 answer
  • 6.   If you enter 234.567 into a cell that is formatted to display 1 decimal place, what is the value stored in the cell?
    15·2 answers
  • I have an airsoft pistol and I needed to take it apart to repair it and I lost some screws that were tiny and I dont know what t
    14·1 answer
  • Help me asap please
    15·1 answer
  • Drag the tiles to the correct boxes to complete the pairs.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!