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
Write a statement to declare a variable x with data type int and initialise with the value 10​
nexus9112 [7]

Answer:

int x = 10;

Explanation:

This would work in many languages (C/C++/C#/Java).

6 0
2 years ago
As data travels further over a wavelength or frequency, what goes down?
LUCKY_DIMON [66]

As data travels further over a wavelength or frequency, the radiation type goes down.

<h3>What is an electromagnetic spectrum?</h3>

An electromagnetic spectrum can be defined as a range of frequencies and wavelengths into which an electromagnetic wave is distributed into.

In Science, the electromagnetic spectrum consist of the following types of energy from highest to lowest frequency and shortest to longest wavelength:

  • Gamma rays
  • X-rays
  • Ultraviolet radiation
  • Visible light
  • Infrared radiation
  • Microwaves
  • Radio waves

In this context, we can infer and logically deduce that as data travels further over a wavelength or frequency within the electromagnetic spectrum, the radiation type goes down.

Read more on electromagnetic spectrum here: brainly.com/question/23423065

#SPJ1

5 0
1 year ago
You plan to use the Fill Down feature on a formula and you need to keep a cell reference the same. Which of the following format
yKpoI14uk [10]
A $E19 I now it because I am in college
6 0
3 years ago
Read 2 more answers
HOWDOYOUDOASPACE?<br><br><br><br> I can't figure out how to make a space on my computer?
e-lub [12.9K]
Depending on the type of keyboard, all spacebars are at the bottom middle of your keyboard and is the largest part of the keyboard.
6 0
3 years ago
Read 2 more answers
Which of these is not a sub-claim "Our Clean Power Plan" uses to support its main claim? The CPP protects public health. The CPP
Leno4ka [110]
The CPP cleans the air statement is not a sub-claim of Our Clean Power Plan.

It is the efforts of President Barrack Obama and the U.S. Environmental Protection Agency that has the main goal of lessening to cutting carbon pollution from the present power plants
4 0
3 years ago
Read 2 more answers
Other questions:
  • Which part of the cryosphere comes directly from the atmosphere?
    13·2 answers
  • Never mind I got it
    8·2 answers
  • Why would a brokered CD pay more than a regular CD?
    13·1 answer
  • Drag the tiles to the correct boxes to complete the pairs.
    6·1 answer
  • science and technology are interdependent advances in one lead to advances in the other. give an example of this phenomenon.
    5·1 answer
  • Does coaxial cable use radio waves to transmit data
    10·2 answers
  • Freeeee BRAINLIESTHBJHBJHB
    8·2 answers
  • If any one answered this i will give brilientst what is stimulation program​
    6·1 answer
  • What is the difference between a loop and a function?
    7·2 answers
  • Question 5 / 15
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!