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
A group of computers that are interconnected in order to share information or documents is called a
zaharov [31]

Answer:

computer network

Explanation:

group of computers that are interconnected in order to share information or documents.

4 0
3 years ago
A set of programs that enable hardware to process data is
andreyandreev [35.5K]
C. the database as in the name is the base of everything.
8 0
4 years ago
One difference between Windows 3.0 and Windows 2.0 was that users could no longer use MS-DOS commands to operate their computer.
Kipish [7]

the answer is false.

6 0
3 years ago
Select the correct answer.
zmey [24]

Answer: data design model

Explanation:

8 0
3 years ago
Which social network made the mistake of alienating its early adopters by deleting suspicious accounts?​?
mamaluj [8]
<span>Which social network made the mistake of alienating its early adopters by deleting suspicious accounts?
Ryze
Friendster
SixDegrees
Tribe.net
MySpace


The Correct answer is </span>Friendster.
5 0
4 years ago
Other questions:
  • They predicted another cold day in Seattle. They predicted another windy day in Seattle. Combine the sentences into one sentence
    8·1 answer
  • Write a program that estimates the approximate number of times the user’s heart has beat in his/her lifetime using an average he
    12·1 answer
  • Race conditions are possible in many computer systems. Consider a banking system with two methods: deposit(amount) and withdraw(
    14·1 answer
  • What are 3 characteristics of syndrome E?
    13·1 answer
  • Given that a method receives three parameters a, b, c, of type double, write some code, to be included as part of the method, th
    8·1 answer
  • #In chemistry, the ideal gas law states:
    5·1 answer
  • The central device on a network that provides a common connection point for nodes on that network is called the
    8·1 answer
  • The declaration of variables begins with a command a. dim b. rem c. const​
    8·1 answer
  • This program will output a right triangle based on user specified height triangleHeight and symbol triangleChar. It is strongly
    14·1 answer
  • 13. You're doing research for a paper. When would you use an indirect citation?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!