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 10:30
What can tanya do now to start preparing for the college and scholarship application process? think about her grades, activities in which she can get involved, possible part-time jobs at which she can work, and standardized tests she can take. (10 points) apex
Answers: 2
question
Computers and Technology, 22.06.2019 15:00
Hyperactive media sales has 10 windows 7 laptop computers used by sales-people in the organization. each laptop computer has several customized applications that are used during the sales process as well as customer relationship management software. all of the applications on the laptops are difficult to configure and have large data files. if all of the laptops have current hardware, what is the easiest way to install windows 10 on them?
Answers: 1
question
Computers and Technology, 22.06.2019 21:30
Write a function named printfloatrepresentation(float number) that will print the floating point representation of a number using the format given below. (sign bit) exponent in binary (assumed bit).significandfor example if the number passed an argument is 71 yourprogram should print (0) 10000101 (1).00011100000000000000000similarly if the number passed to the function as argument is -71 the program should print (1) 10000101 (1).00011100000000000000000
Answers: 3
question
Computers and Technology, 22.06.2019 23:00
Which type of tab stop is most for weights and measurements?
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, 14.09.2020 06:01
question
Mathematics, 14.09.2020 06:01
question
Mathematics, 14.09.2020 06:01
question
Mathematics, 14.09.2020 06:01
question
Health, 14.09.2020 06:01
question
Health, 14.09.2020 06:01
question
History, 14.09.2020 06:01
question
Mathematics, 14.09.2020 06:01
question
Mathematics, 14.09.2020 06:01
question
Mathematics, 14.09.2020 06:01
question
English, 14.09.2020 06:01
question
Chemistry, 14.09.2020 06:01
question
Mathematics, 14.09.2020 06:01
question
Social Studies, 14.09.2020 06:01
question
Mathematics, 14.09.2020 06:01
question
Social Studies, 14.09.2020 06:01
question
Mathematics, 14.09.2020 06:01
question
Mathematics, 14.09.2020 06:01
question
Mathematics, 14.09.2020 06:01
question
Mathematics, 14.09.2020 06:01
Questions on the website: 13722367