Answer:
Follows are the code to this question:
#include <iostream>//defining a header file
using namespace std; //using namespace
int main() //defining main method
{
int red,green,blue,s; //defining integer variable
cout<<"Enter value: \\ ";//print message
cin>>red>>green>>blue; //input value
if(red<green && red<blue)//defining if block that checks red value
s=red;//store red variable value to s variable
else if(green<blue)//defining else if block that checks green value less then blue
s=green;//store green variable value in s variable
else//defining else block
s=blue; //store blue variable value in s variable
//calculating red, green, blue value
red=red-s;//store red value
green=green-s;//store green value
blue=blue-s;//store blue value
cout<<red<<" "<<green<<" "<<blue;
}
Output:
Enter value:
130
50
130
80 0 80
Explanation:
In the above code, inside the Main method, four integer variable "red, green, blue, and s" is 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, that checks the red variable value, if the condition is true, it will store its value in the "s" variable, otherwise, it will go to else if block.
- In this block, the green variable checks its value less than then blue variable value, if the condition is true, it will store the green value in the "s" variable, otherwise, it will goto else block.
- In this block, it will store the blue variable value in the "s" variable, and subtract the value of "red, green, and blue" value from "s" and store its value, and at the last, it will print its value.