subject

C++ 12.18 Lab - Structs
In this lab, you will familiarize yourself with structs through a small exercise. We will be mixing the RGB values of colors together to make a new one.
RGB stands for red, green and blue. Each element describes the intensity value ranging from 0 - 255. For example: black color will have RGB values (0, 0, 0) while white will have (255, 255, 255).
Create an array of structs color. The struct contains three integers named red, green and blue. This corresponds to the RGB values of a color. For each array element, ask the user to enter the intensity value of red, green and blue. The value should be between 0 and 255 (inclusive).
The user can enter at most 10 colors. . see below for inputs
Additionally, compute the average of each of the red, green and blue components. For code modularity, implement a function that returns the average of each rgb component in your dynamic array. The function (called average) should take in a struct array, the rgb type for which you want to compute the average (as a string - red, blue or green) and its length. Print out the final result in the form (r, g, b), where r, g, b corresponds to each averaged value.
Can you guess what color you mixed? (Note: Your program does not need to print the final color mixed)
TEST #1
Input >>> 0 0 2 2 4 2
Expected output >>>> (1, 2, 2)
TEST #2
Input >>> 245 220 5 43 56 21 234 56 43
Expected output >>>> (174, 110, 23)
TEST #3
Input >>> 225 221 2 43 56 21 224 56 43 120 110 24 25 25 27
Expected output >>>> (127, 93, 23)
TEST #4
Input >>> 245 22 34
Expected output >>>> (245, 22, 34)

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 14:00
Which database model is best used for data warehouse and data mining
Answers: 3
question
Computers and Technology, 24.06.2019 06:30
Some peer-to-peer networks have a server and some don't. true false
Answers: 2
question
Computers and Technology, 24.06.2019 12:50
What percentage of teens plays video games? a.97% b.100% c.74% d.50%
Answers: 1
question
Computers and Technology, 25.06.2019 06:00
Shaniya has misspelled a scientific name in her biology report. she needs to correct it, but she has no access to a computer. she plans to use the word app on her phone without an office 365 subscription. can shaniya correct her mistake? why or why not? yes, she can navigate the window and do simple editing. yes, she can use this application for free and navigate the window. no, her document is “read-only,” so she cannot navigate the window. no, her application has limited features and she cannot access the documen
Answers: 1
You know the right answer?
C++ 12.18 Lab - Structs
In this lab, you will familiarize yourself with structs through a sma...
Questions
question
Mathematics, 18.09.2020 17:01
question
Mathematics, 18.09.2020 17:01
question
Mathematics, 18.09.2020 17:01
question
Mathematics, 18.09.2020 17:01
question
History, 18.09.2020 17:01
question
Mathematics, 18.09.2020 17:01
question
Mathematics, 18.09.2020 17:01
question
Mathematics, 18.09.2020 17:01
question
Mathematics, 18.09.2020 17:01
question
Mathematics, 18.09.2020 17:01
question
Social Studies, 18.09.2020 17:01
question
Mathematics, 18.09.2020 17:01
question
Mathematics, 18.09.2020 17:01
question
Mathematics, 18.09.2020 17:01
question
Mathematics, 18.09.2020 17:01
question
Mathematics, 18.09.2020 17:01
question
Mathematics, 18.09.2020 17:01
question
Mathematics, 18.09.2020 17:01
question
Mathematics, 18.09.2020 17:01
question
Social Studies, 18.09.2020 17:01
Questions on the website: 13722363