Question
In c++ In this lab, you will familiarize yourself with structs through a small exercise. We will be mixing the RGB values of colors together
In c++
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 a dynamic 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).
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 should take in a struct array, its length and the rgb type for which you want to compute the average. 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)
1: Test #1 0/20 Input 2 0 022 4 2 Expected Output 2: Test #2 0/20 nput 3 245 220 5 43 56 21 234 56 43 Expected Output (174, 110, 23) 3: Test #3 0/20 Input 1 245 22 34 Expected Output (245, 22, 34)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started