Answered step by step
Verified Expert Solution
Question
1 Approved Answer
- 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 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
Step: 1
Get Instant Access with AI-Powered 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