Question: - The color code in computer system can be represented in 2 ways: - R: 255 G: 0 B: 0 0xFF0000 - Write a program

- The color code in computer system can be represented in 2 ways: - R: 255 G: 0 B: 0 0xFF0000 - Write a program to ask values of R, G, B, and print out the values as 0 format. Requirements - Create a struct and union to store different interpretation of color code (2pt). - Ask users to enter values of R, G, B (1pt). - Store the RGB values into a struct (2pt). - Retrieve the hexadecimal format from an integer that is the union of RGB struct (2pt). Steps as Hints - Create a struct for RGB with 3 members: - struct RGB ( unsigned char B; unsigned char G; unsigned char R; \} - Create unsigned int code, union with struct RGB. - Ask values for R, G, B from users by std::"cin. - Assign values of RGB into the members of struct RGB respectively. - Retrieve the RGB code by its union member unsigned int code. - Output the unsigned int code. as hexadecimal: - cout
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
