Chapter 4: Problem 11
include
Short Answer
Step by step solution
Key Concepts
These are the key concepts you need to understand to accurately answer the question.
/*! This file is auto-generated */ .wp-block-button__link{color:#fff;background-color:#32373c;border-radius:9999px;box-shadow:none;text-decoration:none;padding:calc(.667em + 2px) calc(1.333em + 2px);font-size:1.125em}.wp-block-file__button{background:#32373c;color:#fff;text-decoration:none}
Learning Materials
Features
Discover
Chapter 4: Problem 11
include
These are the key concepts you need to understand to accurately answer the question.
All the tools & learning materials you need for study success - in one app.
Get started for free
Mark the following statements as true or false. a. The result of a logical expression cannot be assigned to an int variable. b. In a one-way selection, if a semicolon is placed after the expression in an if statement, the expression in the if statement is always true. c. Every if statement must have a corresponding else. d. The expression in the if statement: if (score = 30) grade = 'A'; always evaluates to true. e. The expression: (ch >= 'A' && ch <= 'Z') evaluates to false if either ch < 'A' or ch >= 'Z'. f. Suppose the input is 5. The output of the code: cin >> num; if (num > 5) cout << num; num = 0; else cout << "Num is zero" << endl; is: Num is zero g. The expression in a switch statement should evaluate to a value of the simple data type. h. The expression !(x > 0) is true only if x is a negative number. i. In C++, both ! and != are logical operators. j. The order in which statements execute in a program is called the flow of control.
Write C++ statements that output Male if the gender is 'M", Female if the gender is ' \(\mathrm{F}^{\prime}\), and invalid gender otherwise.
Suppose the input is 3. What is the value of beta after the following C++ code executes? cin >> beta; switch (beta) { case 3: beta = beta + 3; case 1: beta++; break; case 5: beta = beta + 5; case 4: beta = beta + 4; }
Correct the following code so that it prints the correct message. if (score >= 60) cout << "You pass." << endl; else; cout << "You fail." << endl;
Suppose the input is 6. What is the value of a after the following C++ code executes? cin >> a; if (a > 0) switch (a) { case 1: a = a + 3; case 3: a++; break; case 6: a = a + 6; case 8: a = a * 8; break; default: a--; } else a = a + 2;
What do you think about this solution?
We value your feedback to improve our textbook solutions.