4.17-4.22

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

What will the following program segment display? int funny=1, serious; if(funny!=1) { funny=serious=1; } else if(funny==2) { funny=serious=3; } else { funny=serious=5; } cout<<funny<<" "<<serious<<endl;

5 5

The following program is used in a bookstore to determine how many discount coupons a customer gets. Complete the table that appears after the program. #include <iostream> using namespace std; int main() { int numBooks, numCoupons; cout << "How many books are being purchased?"; cin >> numBooks; if (numBooks < 1) numCoupons = O; else if (numBooks < 3) numCoupons = 1; else if (numBooks < 5} numCoupons = 2; else numCoupons = 3; cout << "The number of coupons to give is"<< numCoupons << endl ; return 0; } --------------------- Coupons for... 1 2 3 4 5 10

1 1 2 2 3 3

If you execute the following code, what will it display if the user enters 15 18? 15 10? 9 7? cout <<" Enter the number of team wins and number of team losses : "; cin >> teamWins>> teamlosses ; if (teamWins > teamlosses) { if (teamWins > 10) cout << "You are the champions. \n"; else cout << "You have won more than 50% of your games. \n"; } else cout << "Good luck in the rest of your games. "·

Good luck in the rest of your games. You are the champions You have won more than 50% of you games.

If you execute the following code, what will it display if the user enters 5? 15? 30? -1? cout<<"Enter a number: " cin>>number; if(number>0) { cout<<"Zero "; if (number>10) { cout<<"Ten"; if(number>20) { cout<<"Twenty"; } } }

Zero ZeroTen ZeroTenTwenty nothing

Write an if/else if statement that carries out the following logic. If the value of variable quantityOnHand is equal to 0, display the message "Out of stock" . If the value is greater than 0, but less than 10, display the message "Reorder". If the value is 10 or more, do not display anything .

if(quantityOnHand==0) cout<<"Out of stock"; else if(quantityOnHand>0&&quantityOnHand<10) cout<<"Reorder";

Write an if/else if statement that performs the same actions as in the above question when the value of quantityOnHand is equal to 0 or is greater than 0, but less than 10. However, when the value is 10 or more, it should display the message "Quantity OK"

if(quantityOnHand==0) cout<<"Out of stock"; else if(quantityOnHand>0&&quantityOnHand<10) cout<<"Reorder"; else cout<<"Quantity OK";


Set pelajaran terkait

Substance use disorders Varcarolis

View Set

Strategic Management Assignment 8

View Set

National income and price determination Unit Test

View Set

Chapter 2 - Policy Provisions and Contract Law

View Set

Combo with "ch 12 nervous system" and 1 other

View Set