Answer:
Follows are the code to this question:
#include<iostream>//defining header file
using namespace std;// use package
int main()//main method
{
int red,green,blue,x;//declaring integer variable
cin>> red >>green>>blue;//use input method to input value
if(red<green && red<blue)//defining if block that check red value is greater then green and blue
{
x = red;//use x variable to store red value
}
else if(green<blue)//defining else if block that check green value greater then blue
{
x= green; //use x variable to store green value
}
else//defining else block
{
x=blue;//use x variable to store blue value
}
red -= x;//subtract input integer value from x
green -=x; //subtract input integer value from x
blue -= x;//subtract input integer value from x
cout<<red<<" "<<green<<" "<<blue;//print value
return 0;
}
Output:
130 50 130
80 0 80
Step-by-step explanation:
In the given code, inside the main method, four integers "red, green, blue, and x" are defined, in which "red, green, and blue" is used for input the value from the user end. In the next step, a conditional statement is used, in the if block, it checks red variable value is greater than then "green and blue" variable. If the condition is true, it will store red variable value in "x", otherwise, it will goto else if block.
- In this block, it checks the green variable value greater than the blue variable value. if the condition is true it will store the green variable value in x variable.
- In the next step, else block is defined, that store blue variable value in x variable, at the last step input variable, is used that subtracts the value from x and print its value.