Hi again folks,
Currently I am trying to make a program that will give the hexadecimal value of a colour based upon the RGB values. This is the code that I have:
Code:
/* RGBtoHEX - A program designed to convert colours in RGB to Hexadecimal value */
#include <stdio.h>
main()
{
int red;
int green;
int blue;
printf("Please enter the value for Red: ");
scanf("%d",&red);
printf("Please enter the value for Green: ");
scanf("%d", &green);
printf("Please enter the value for Blue: ");
scanf("%d", &blue);
printf("\nThe hexadecimal value for your colour is #%X%X%X.", red, green, blue);
return 0;
}
Currently, the line
Code:
printf("\nThe hexadecimal value for your colour is #%X%X%X.", red, green, blue);
,
will only correctly work for high values of R, G and B. I would like to know if you can transform, for example F to 0F, just for clarity in the output.
Any help is greatly appreciated,
mintsmike