Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Does the following expression evaluate to a true value or a false value in C++?

ID: 3563725 • Letter: D

Question

Does the following expression evaluate to a true value or a false value in C++?

(5 <= 7) && !(3 != 3)

Does the following expression evaluate to a true value or a false value in C++?

(2 * 3 < 5) || (2 * 5 < 3)

Does the following expression evaluate to a true value or a false value in C++?

"ASU" >= "Arizona State University"

What is the output after the execution of the following code, assuming that user inputs the value 5 for num?

int num;
cin >> num;   // assume user enters 5

if (num > 0)
num = num + 10;
else
num = num + 15;

cout << num << endl;

What is the output of the following statements?

double x = -1.5;

if (x < -1.0)
    cout << "true ";
else
    cout << "false ";
    cout << "after if...else" << endl;

true

false

false after if...else

true after if...else

Consider the following scenario where a dry cleaner offers the following discounts based on the number of shirts to be cleaned:

Number of Shirts     Discount:

fewer than 10   0%
10 or more               10%

Write a C++ code segment (not a full program) that prompts the user for the number of shirts required and then displays the appropriate discount.

For example, if the the user entered 13, then your code should output "Your discount is 10%."
And if the user entered 3 the output should be "Your discount is 0%."

true

false

false after if...else

true after if...else

Consider the following scenario where a dry cleaner offers the following discounts based on the number of shirts to be cleaned:

Number of Shirts     Discount:

fewer than 10   0%
10 or more               10%

Write a C++ code segment (not a full program) that prompts the user for the number of shirts required and then displays the appropriate discount.

For example, if the the user entered 13, then your code should output "Your discount is 10%."
And if the user entered 3 the output should be "Your discount is 0%."

Explanation / Answer

1.Does the following expression evaluate to a true value or a false value in C++?
   (5 <= 7) && !(3 != 3)
  
Answer: Return true
  

2. Does the following expression evaluate to a true value or a false value in C++?
   (2 * 3 < 5) || (2 * 5 < 3)
  
   Answer: Return false
  
3. Does the following expression evaluate to a true value or a false value in C++?
   "ASU" >= "Arizona State University"
  
   Answer: Return false
  
4. What is the output after the execution of the following code, assuming that user inputs the value 5 for num?
   int num;
   cin >> num; // assume user enters 5

   if (num > 0)
       num = num + 10;
   else
       num = num + 15;
   cout << num << endl;


   Answer: 15

5. What is the output of the following statements?
   double x = -1.5;

   if (x < -1.0)
   cout << "true ";
   else
   cout << "false ";
   cout << "after if...else" << endl;
  
   Answer: true after if...else

==================================

Program:

=================================

#include <string>

void main () //start of main fcn
{

   int noOfShirts;
   cout<<"Enter Number of shirts ";
   cin>>noOfShirts;
   if(noOfShirts>=10)
       cout<<"Your discount is 10%.";
   else
       cout<<"Your discount is 0%.";
}  

==============================

Output

==============================

Enter Number of shirts
13
Your discount is 10%.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote