Question

Write the output of the following cout statements, showing the steps of your work. auto value_1...

Write the output of the following cout statements, showing the steps of your work.
auto value_1 = -1, value_2 = -4, value_3 = 9;
if (value_1 == value_2 || value_3 / 3 > value_2)
{
if (value_1 - 2 * value_2 == 1)

cout << "A";
else if (value_3 * -1 > 0)

cout << "B";
} else {
cout << "C"; }

Homework Answers

Answer #1

Answer:

This will code print nothing, as it may show the "Program finished with exit code 0 " on the console window.

Explanation:

We will run code line by line.

Given values, auto value_1 = -1, value_2 = -4, value_3 = 9;

if (value_1 == value_2 || value_3 / 3 > value_2) that is (-1 == -4 || 9/3 > -4) condition is true as 3>-4 will move into if.

now check inner if statement

if (value_1 - 2 * value_2 == 1) i.e. (-1 -2 * -4 == 1 ) which is false as (7 !=1)

so will move to else if condition.

else if (value_3 * -1 > 0) i.e. (9 * -1 > 0) which is false as -8 is not greater than 0

As we can see that there is no else statement, so it would print nothing and program will exit with code 0.

Note: It would not also print C as outer if condition is true, so will not go to else.

Please give thumbsup, or do comment in case of any query. Thanks.

Know the answer?
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
Similar Questions
Re-write following if-else-if statements as Switch statement. Your final code should result in the same output...
Re-write following if-else-if statements as Switch statement. Your final code should result in the same output as the original code below. if (selection == 10) System.out.println("You selected 10."); else if (selection == 20) System.out.println("You selected 20."); else if (selection == 30) System.out.println("You selected 30."); else if (selection == 40) System.out.println("You selected 40."); else System.out.println("Not good with numbers, eh?"); Second question Re-write following while loop into Java statements that use a Do-while loop. Your final code should result in the same...
2- Use a conditional operator to fill in the underlined part of the "cout" statement to...
2- Use a conditional operator to fill in the underlined part of the "cout" statement to make the following code prints either “is equal to C++” or “is not equal to C++” depending on value of the string. Put your entire code only inside the blank spaces in parentheses and do not modify other parts of the code. (4 pts): string st; cout << "Enter a string:"; cin >> st; cout << "String " << st <<              (........................................................................................) ; 3-...
Instructions Write a program that produces the following output: CCCCCCCCC ++ ++ CC ++ ++ CC...
Instructions Write a program that produces the following output: CCCCCCCCC ++ ++ CC ++ ++ CC ++++++++++++++ +++++++++++++++ CC ++++++++++++++ +++++++++++++++ CC ++ ++ CCCCCCCCC ++ ++ Note: The letter C in the output must be uppercase. #include <iostream> using namespace std; int main() {   cout<<"CCCCCCCCC ++ ++ CC ++ ++ CC ++++++++++++++ +++++++++++++++ CC +++++++++++++\n";   cout<<"+++++++++++++++ CC ++ ++ CCCCCCCCC ++ ++";   return 0; } this is my woek #include <iostream> using namespace std; int main() { cout<<"CCCCCCCCC ++...
Re-write following if-else-if statements as Switch statement. Your final code should result in the same output...
Re-write following if-else-if statements as Switch statement. Your final code should result in the same output as the original code below. if (selection == 10) System.out.println("You selected 10."); else if (selection == 20) System.out.println("You selected 20.") ; else if (selection == 30) System.out.println("You selected 30."); else if (selection == 40) System.out.println("You selected 40."); else System.out.println("Not good with numbers, eh?");
e-write following if-else-if statements as Switch statement. Your final code should result in the same output...
e-write following if-else-if statements as Switch statement. Your final code should result in the same output as the original code below. if (selection == 10) System.out.println("You selected 10."); else if (selection == 20) System.out.println("You selected 20."); else if (selection == 30) System.out.println("You selected 30."); else if (selection == 40) System.out.println("You selected 40."); else System.out.println("Not good with numbers, eh?"); (Java programming)
write a Nested loop in C# to print out the following output using windows form. 0...
write a Nested loop in C# to print out the following output using windows form. 0 0 1 0 2 4 0 3 6 9 0 4 8 16 32
Given the following program segment….             for (num = 10; num >= 1; num--)            cout...
Given the following program segment….             for (num = 10; num >= 1; num--)            cout << setw(3) << num; Write a while loop that will have the same output. C++
Q1: Re-write following if-else-if statements as Switch statement. Your final code should result in the same...
Q1: Re-write following if-else-if statements as Switch statement. Your final code should result in the same output as the original code below. if (selection == 10) System.out.println("You selected 10."); else if (selection == 20) System.out.println("You selected 20."); else if (selection == 30) System.out.println("You selected 30."); else if (selection == 40) System.out.println("You selected 40."); else System.out.println("Not good with numbers, eh?"); Q2: Re-write following while loop into Java statements that use a Do-while loop. Your final code should result in the same...
Write a C function to compute the following output (int) based on two input (int) variables:...
Write a C function to compute the following output (int) based on two input (int) variables: output = a*a + b*b - 2*a*b If the value of output is '0', then return -1 instead. Call the C function 4 times from main() with values of 'a' and 'b' as follows and print output values for each case. a = 3, b = 4 a = 1, b = 1 a = -2 b = 3 a = -4 b =...
Calculate (showing your work) the price of the following 2-year bonds when the yields on similar...
Calculate (showing your work) the price of the following 2-year bonds when the yields on similar assets are 4 percent and the bonds have $100 face values and annual coupons of: (a) 3 percent; (b) 4 percent; (c) 5 percent.