Task 8-Create color-RGB value-solution
To determine which color dominates, you must first enter 3 integers, and then determine which number is the largest. The task is similar to the task that requires a maximum value of 3 integers:
7. Task 7-Minimum of three integers-solution
7. Task 7-Minimum of three integers-solution
There is a possibility that two color components have the same value, as well as that all three are the same.
Solution:
Solution:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int R,G,B;
printf("Enter the R, G, B value");
scanf("%d%d%d", &R, &G, &B);
if(R>G && R>B)
{
printf("Dominated by red");
}
else if(G>R && G>B))
{
printf("Dominated by green");
}
else if(B>R && B>G))
{
printf("Dominated by blue");
}
else if(B==R && B>G))
{
printf("A mixture of blue and red dominates");
}
else if(G==B && G>R))
{
printf("A mixture of blue and green dominates");
}
else if(R==G && R>B))
{
printf("A mixture of green and red dominates");
}
else if(B==R && B==G))
{
printf("All three colors are equally represented");
}
return 0;
}
#include <stdlib.h>
int main()
{
int R,G,B;
printf("Enter the R, G, B value");
scanf("%d%d%d", &R, &G, &B);
if(R>G && R>B)
{
printf("Dominated by red");
}
else if(G>R && G>B))
{
printf("Dominated by green");
}
else if(B>R && B>G))
{
printf("Dominated by blue");
}
else if(B==R && B>G))
{
printf("A mixture of blue and red dominates");
}
else if(G==B && G>R))
{
printf("A mixture of blue and green dominates");
}
else if(R==G && R>B))
{
printf("A mixture of green and red dominates");
}
else if(B==R && B==G))
{
printf("All three colors are equally represented");
}
return 0;
}