COM SCI 31 Lecture Notes - Lecture 4: Uninitialized Variable, Newline, Negative Number

40 views7 pages

Document Summary

/* will print a garbage, unpredictable value didn"t initialize g output is a leftover value from an earlier computation most common garbage value for uninitialized variable is 0 but not always 0. Sir robin is delivered to program cout << what is your quest? string quest; getline(cin, quest); cout << hello, brave << personsname << ! If you live, next year you will be 33. #include // i/o = input/output. cout, cin, endl, etc. Sir robin is delivered to program cout << how old are you? int age; cin >> age; cin. ignore(10000, /n"); /* explained below. put it in right after reading in number before reading in next string. << endl; cout << you want << quest << endl; cout << if you live, next year you will be << (age + 1) << endl; //without parentheses, does plus operator have less precedence than < safer just to put parentheses. although + does have higher precedence than output:

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents