Answer:
The programming language is not stated; However, I'll answer the question using C++ programming language,
This program uses comments for explanations
Program starts here
#include<iostream>
using namespace std;
int main()
{
//Declare Array
int colorcode[3],graycode[3];
//Prompt user for color code
cout<<"Enter Color Code (One on a line)"<<endl<<"Inout Range is 0 to 255"<<endl;
for(int i = 0;i<3;i++)
{
ccode:
cout<<"Enter Color Code "<<i+1<<": ";
cin>>colorcode[i];
if(colorcode[i]<0 || colorcode[i]>255)
{
cout<<"Input Range is 0 to 255"<<'\\';
goto ccode;
}
}
//Initialize smallest to colorcode[0]
int smallest = colorcode[0];
//Determine smallest
for(int i = 0;i<3;i++)
{
if(colorcode[i]<smallest)
{
smallest = colorcode[i];
}
}
//Determine Graycode
for(int i = 0;i<3;i++)
{
graycode[i] = colorcode[i] - smallest;
}
//Display Result:
cout<<"Color Code: "<<"(";
for(int i = 0;i<3;i++)
{
if(i!=2)
{
cout<<colorcode[i]<<",";
}
else
{
cout<<colorcode[i]<<")"<<endl;
}
}
cout<<"Gray Code: "<<"(";
for(int i = 0;i<3;i++)
{
if(i!=2)
{
cout<<graycode[i]<<",";
}
else
{
cout<<graycode[i]<<")"<<endl;
}
}
return 0;
}