



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
An overview of formatting output and inputting strings in C++. It covers topics such as setting output width, precision, and justification using manipulators, as well as reading whole lines of text and handling leading whitespace with cin and getline. The document also emphasizes the importance of hand tracing for analyzing and understanding code.
Typology: Lecture notes
1 / 6
This page cannot be seen from the preview
Don't miss anything!
1
05/06/^
3
Price ------ -----------------^
10041 Hammer^
16334 Book on C++^
29169 Cowboy hat^
21478 USB Memory Stick (8Gig)
36962 Cellular phone^
15705 Pens (assorted)^
33281 Pizzas (anchovies & cheese)
19961 Gum^
12995 Hybrid vehicles^
14827 Staples^
Total^
5
Pads with spaces whenitem is fewer charactersthan the setw()'s width.if it's larger than width.^ setw.cpp
05/06/^
Name:^ Fav Food^ Fav NumberDr. Evil^ Cupcakes^100000000 I.L.B. Bach^ Anchovies^
1997 Me^ Pizza and Cake^
(^0) setwTable.cpp 7
3.141593.142Value is3.14rounded.3.1 3 3.14159265 setprecision.cpp^
05/06/^
Cost 1: 1.99Cost 2: 3.55Cost 3: 2.10Cost 4: 1.00Cost 5: 1 1.23457e+00712345678.90000012345678.90cout << fixed << setprecision(2);cout << "Cost 1: " << 1.9876 << endl;cout << "Cost 2: " << 3.55 << endl;cout << "Cost 3: " << 2.1 << endl;cout << "Cost 4: " << 1.0 << endl;cout << "Cost 5: " << 1 << endl; Big number defaults toscientific notation.fixed avoids sci. notn.Default precision...fixed + setprecision(2)gives 2 digits after .fixed and setprecision()no effect on integers.fixed.cpp
15
05/06/^
Input "Evil",press ENTER.E v^ i^ l^ \n lastName gets "Evil",'\n' left in cin buffer.Reads in the extra '\n',sets fullName to 17
05/06/^
Last name:^ Evil Full name:^ Dr Evil Secret Agent Program:^ Input stream (read by cin):
Desired Operation:
19
Input "Evil",press ENTER.E v^ i^ l^ \n lastName gets "Evil",'\n' left in cin buffer.Input "Dr Evil";sets fullName to"Dr Evil"^ 05/06/
Last name:^ Evil Full name:^ Dr Evil Secret Agent Program:^ Input stream (read by cin):
Desired Operation: 22 Hand DebuggingSection 3.
05/06/^