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
In the computer science industry, the process of finding and removing errors from computer hardware or software is known as
Katyanochek1 [597]
Debugging i think it is
3 0
3 years ago
Yazmin is reading a book that has 74 pages. She has read 38 pages. How many more pages does she need to read to finish the book​
Brut [27]

Answer:

36 book

im sure it is correct

4 0
3 years ago
What of the following can a cell contain? A number a word a function of these
EastWind [94]
A function of these
8 0
3 years ago
Jason needs to renew the certificate for his company’s web server. Which of the following is recommended to be submitted to the
notsponge [240]

Answer:

A. CSR

Explanation:

CSR, (certificate signing request also known as certification request, CR) are messages sent by an applicant to a certificate authority to acquire a digital identification certificate or renew an already existing one. It contains information of the client or applicant like domain name, public key etc.

Keyescrow, CRLD and OCSP are not recommended or required for renewing digital certificate as they commands or settings for shortcuts and commands.

3 0
4 years ago
By applying styles, _______ formats are being applied each time. A. various B. different C. the same D. similar
Dmitry [639]
I just took the test on (PF) it's C. the same

i hope this helped someone.
;-)
4 0
4 years ago
Read 2 more answers
Other questions:
  • What is the speed limit in school zone
    11·2 answers
  • Which feature of a word processing program enables you to represent an text information in the form of a diagram?
    14·2 answers
  • A technician is troubleshooting a printer connected to a computer via USB. The printer will print using the controls at the prin
    9·1 answer
  • If you want to distribute a formatted Microsoft word document to people who don't have word save it as a __file
    5·1 answer
  • NAND is logically complete. Use only NAND gates to constructgate-level circuits that compute the
    7·1 answer
  • Advantages of bursaries??????
    11·1 answer
  • Preserving confidentiality, integrity, and availability is a restatement of the concern over interruption, interception, modific
    11·1 answer
  • What are interpersonal skills for non-technical user
    14·1 answer
  • Text me on instagram forever.brazy so we can watch a movie​
    15·1 answer
  • (isc)² certified information systems security professional official study guide 6th editionauthors: stewart, james michael; chap
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!