















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
The key points in these lecture slides of intro to computer programming are given as:Input Output Manipulation, Library Header Files, Classes for Stream, Stream Manipulators, Select Output Precision, Stream Format States, Format Flags, Member Functions, End-Of-File Condition
Typology: Slides
1 / 23
This page cannot be seen from the preview
Don't miss anything!
















Lecture 27
Docsity.com
Note: There is no “.h” on standard header files. Be careful about “ using namespace std ”
Docsity.com
Docsity.com
setprecision ( )
Docsity.com
ios::showpoint when set, show trailing decimal point and zeros
ios::showpos when set, show the + sign before positive numbers
ios::basefield
ios::dec use base ten Docsity.com
ios::floatfield
ios::fixed use fixed number of digits ios::scientific use "scientific" notation
ios::adjustfield
ios::left use left justification ios::right use right justification ios::internal left justify the sign, but right justify the value Docsity.com
.setf ( )
flag.
// To show the + sign in front of positive numbers cout.setf (ios::showpos) ; Docsity.com
.precision ( ) ;
cout.precision (2) ; // two significant digits
.width ( ) ;
.clear ( ) ;
"good" so that I/O may proceed or resume on that stream.
cin.clear ( ) ; // allow I/O to resume on a "bad" // stream, in this case "cin",Docsity.com
#include
Docsity.com
Enter your name
R. J. Freuler
Enter two integers and a float
12 24 67.
Thank you, R. J. Freuler, you entered
12, 24, and 68
Thank you, R. J. Freuler, you entered
12, 24, and 67.85 Docsity.com
.get ( ) ;
Example:
char ch ; ch = cin.get ( ) ; // gets one character from keyboard // & assigns it to the variable "ch"
.get (character) ;
Example: Docsity.com
.getline (array_name, max_size) ;
Example:
char name[40] ; cin.getline (name, 40) ; // Gets up to 39 characters // and assigns the string to "name". A // null is inserted at the end of the string. Docsity.com
.ignore ( ) ;
Ex:
cin.ignore ( ) ; // gets and discards 1 character
cin.ignore (2) ; // gets and discards 2 characters
cin.ignore (80, '\n') ; // gets and discards up to 80 Docsity.com