Question

Using C++ COLOR MIXER- The color red, yellow, and blue are primary colors because they cannot...

Using C++

COLOR MIXER- The color red, yellow, and blue are primary colors because they cannot be made by mixing other colors. When you mix 2 primary colors you get the following:

When you mix red and blue, you get purple.

When you mix red and yellow, you get orange.

When you mix blue and yellow, you get green.

Write a program to ask the user for 2 primary colors (an error if they are not primary). Then display the secondary color you get by mixing them.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code :

#include<iostream>
using namespace std;
int main(){
   string priclr[3]={"red","yellow","blue"};
   string x,y;
   cout<<"Enter the first primary color : ";
   cin>>x;
   cout<<"\nEnter the second primary color : ";
   cin>>y;
   cout<<"======================================================";
   if((priclr[0]==x and priclr[1]==y)||(priclr[0]==y and priclr[1]==x)){
       cout<<"\nSecondary color is : Orange";
   }
   else if((priclr[0]==x and priclr[2]==y)||(priclr[0]==y and priclr[2]==x)){
       cout<<"\nSecondary color is : Purple";
   }
   else if((priclr[2]==x and priclr[1]==y)||(priclr[2]==y and priclr[1]==x)){
       cout<<"\nSecondary color is : Green";
   }
   else{
       cout<<"\nNot a primary color";
   }
   return 0;
}

Screenshot of the code :

Add a comment
Know the answer?
Add Answer to:
Using C++ COLOR MIXER- The color red, yellow, and blue are primary colors because they cannot...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT