[Solved]1 Following Options Checks City Neither Chicago Dallas City Chicago City Dallas City Chica Q37208144
1.Which of the following options checks that city is neitherChicago nor Dallas?
if (city != “Chicago” || city != “Dallas”)
if !(city == “Chicago” || city == “Dallas”)
if !(city == “Chicago” && city == “Dallas”)
if (city != “Chicago” || city == “Dallas”)
2.What is the value of the cost variable after the followingcode snippet is executed?
int cost = 82;if (cost < 100) { cost = cost + 10; }if (cost > 50) { cost = cost * 2; }if (cost < 100) { cost = cost – 20; }
82
92
184
164
3.What is the value of the price variable after the followingcode snippet is executed?
int price = 42;if (price < 40) { price = price + 10; }if (price > 30) { price = price * 2; }if (price < 100) { price = price – 20; }
42
52
84
64
4.A store provides 10% discount on all items with a price of atleast $100. No discount is otherwise applicable. Which of thefollowing statements DOES NOT correctly compute the discount?
double discount = 0; if (price >= 100) { discount = 0.10 * price; }double discount = 0.10 * price; if (price <= 100) { discount = 0; }double discount; if (price < 100) { discount = 0; } else { discount = 0.10 * price; }double discount = 10; if (price >= 100) discount = 0.1 * price; else discount = 0;
5.Which condition, when supplied in the if statement below inplace of (. . .), will correctly protect against division byzero?
if (. . .){ result = grade / num; cout << “Just avoided division by zero!” << endl;}
(grade == 0)
((grade / num) == 0)
(num == 0)
(num != 0)
6.In a switch statement, if a break statement is missing
The break happens at the end of each branch by default
The statement will not compile
Execution falls through the next branch until a break statementis reached
The default case is automatically executed
Expert Answer
Answer to 1.Which of the following options checks that city is neither Chicago nor Dallas? if (city != “Chicago” || city != “Dalla… . . .
OR