Q22 In digital world colors are specified in Red-Green-Blue (RGB) format, with values of R, G, B varying on an interger scale from 0 to 255. In print publishing the colors are mentioned in Cyan-Magenta-Yellow-Black (CMYK) format, with values of C, M, Y, and K varying on a real scale from 0.0 to 1.0. Write a program that converts RGB color to CMYK color as per the following formulae: Note that of the RGB values are all 0, then the CMY values are all 0 and the K value is 1.

Program: 90

In digital world colors are specified in Red-Green-Blue (RGB) format, with values of R, G, B varying on an integer scale from 0 to 255. In print publishing the colors are mentioned in Cyan-Magenta-Yellow-Black (CMYK) format, with values of C, M, Y, and K varying on a real scale from 0.0 to 1.0. Write a c program that converts RGB color to CMYK color as per the following formulae:
While = Max(Red/255, Green/255, Blue/255)
Cyan = (White-Red/255)/(White)
Magenta = (White-Green/255)/(White)
Yellow = (White-Blue/255)/(White)
Black = 1-White
Note that of the RGB values are all 0, then the CMY values are all 0 and the K value is 1.

Output:

Enter the value of Red(0 to 255): 33
Enter the value of Green(0 to 255): 12
Enter the value of Blue(0 to 255): 44
Red: 0.129412
Green: 0.047059
Blue: 0.172549
White: 0.172549

The value of Cyan: 0.250000
The value of Magenta: 0.727273
The value of Yellow: 0.000000
The value of Black: 0.827451

Lokesh Kumar

Being EASTER SCIENCE's founder, Lokesh Kumar wants to share his knowledge and ideas. His motive is "We assist you to choose the best", He believes in different thinking.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.