Question: - The color code in combuter system can be represented in 2wc,s : - R: 255 G: 0 B: 0 0xFF0000 - Write a program

 - The color code in combuter system can be represented in
2wc,s : - R: 255 G: 0 B: 0 0xFF0000 - Write
a program to ask values of R, G, B, and print out

- The color code in combuter system can be represented in 2wc,s : - R: 255 G: 0 B: 0 0xFF0000 - Write a program to ask values of R, G, B, and print out the values as 0x 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 - 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!