nested_if_statements

nested_if_statements - { cout << "You are NOT an...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 #include <iostream> using namespace std int main() { int menuChoice = 0 int numBooks = 0 int numMovies = 0 double numPdsPeanuts = 0.0 cout << "1 books" << endl cout << "2 movies" << endl cout << "3 peanuts" << endl cout << "Enter your choice: " cin >> menuChoice if (menuChoice == 1) { cout << "Enter number of books: " cin >> numBooks if (numBooks > 200 || numBooks < 0) { cout << "IDIOT" << endl } else { // do calculations } } return 0 }// end of main /*
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: { cout << "You are NOT an idiot" << endl } is equivalent to: if (numBooks > 0) { if (NumBooks < 200) { cout << "Not idiot" << endl } } Sheet1 Page 2 ************************************ if (numBooks < 0 || numBooks > 200) { cout << "Idiot" << endl } is equivalent to: if (numBooks < 0} { cout << "idiot" << endl } if (numBooks > 200) { cout << "idiot" << endl } ********************************/...
View Full Document

This note was uploaded on 04/01/2008 for the course CMPSC 101 taught by Professor Drobish,renee during the Spring '07 term at Penn State.

Page1 / 2

nested_if_statements - { cout << "You are NOT an...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online