Program Language C++ Consider the following program: int main() { int a; int b;
ID: 3910842 • Letter: P
Question
Program Language C++
Consider the following program:
int main()
{
int a;
int b;
int c;
cout << “Enter three values for a, b, and c” << endl;
cin >> a;
cin >> b;
cin >> c;
if (a < b)
{
cout << “white“;
}
else if (a < c)
{
cout << “yellow“;
if (a < b)
{
cout << “red“;
}
if (a > b)
{
cout << “blue.“;
}
}
else
{
cout << “green.“;
}
}
1. What is the output if a = 3, b = 5, c = 7? Answer Choices: yellowblue, yellow, green, yellowred, white, red, blue.
2. What is the output if a = 10, b = -5, c = 3? Answer Choices: yellowblue, yellow, green, yellowred, white, red, blue.
3. What is the output if a = 10, b = 0, c = 100? Answer Choices: yellowblue, yellow, green, yellowred, white, red, blue.
Explanation / Answer
Output
1. white
2. green
3. yellowblue
Enter three values for a, b, and c
3 5 7
white
Explanation
3 < 5 is true. So, prints white
Enter three values for a, b, and c
10 -5 3
green
Explanation
10 < -5 is false.
10 < 3 is false.
So, it goes to else to print green
Enter three values for a, b, and c
10 0 100
yellowblue
Explanation
10 < 0 is flase
10 < 100 is true for else if condition
So, prints Yellow.
10 > 0 is true to print blue
Output
1. white
2. green
3. yellowblue
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.