Title: ICOM%204015%20Advanced%20Programming
1ICOM 4015 Advanced Programming
- Lecture 1
- Computer/Human Interaction
- (Part I)
- Reading Chapter 11
- (Up to I/O manipulators)
Prof. Bienvenido Velez
2Computer/Human InteractionOutline
- Administrivia
- Output Streams
- Input Streams
3Administrivia
- Read Chapters 1-2 DeitelDeitel
- Lab meeting times changed
- Please sign up for a lab
- No labs this week
- Tas email email addresses
- Jose Torres (jet_at_amadeus.uprm.edu)
- Jairo Valiente (jvaliente_at_amadeus.uprm.edu)
- Accounts _at_ amadeus ready
- USER Ids derived from student
4Example 1
include ltiostreamgt main() for(int i0
ilt10 i) for(int j0 jlti j)
cout ltlt "" cout ltlt endl
example1.cc
output
5Example 2
include ltiostreamgt main() for(int i0
ilt10 i) for(int j0 jlti j)
cout ltlt "" cout ltlt " " ltlt i ltlt "
stars" cout ltlt endl
example2.cc
0 stars 1 stars 2 stars 3 stars 4
stars 5 stars 6 stars 7
stars 8 stars 9 stars
output
6OutputStream insertion operator
returns an output stream
cout ltlt expression
stream insertion operator
output stream
argument expression
7Example 3
include ltiostreamgt main() int entered
cout ltlt Enter number of rows " cin gtgt
entered for(int i0 iltentered i)
for(int j0 jlti j) cout ltlt ""
cout ltlt " " ltlt i ltlt " stars" cout ltlt
endl
example3.cc
bvelez_at_amadeus gtgt example3 Enter number of
rows 7 0 stars 1 stars 2 stars 3
stars 4 stars 5 stars 6
stars bvelez_at_amadeus gtgt
shell
8Example 4
include ltiostreamgt main() while (true)
cout ltlt " Enter number of rows (-1 to end) "
int entered cin gtgt entered if
(entered -1) break for(int i0
iltentered i) for(int j0 jlti j)
cout ltlt "" cout ltlt " " ltlt
i ltlt " stars" cout ltlt endl
example4.cc
bvelez_at_amadeus gtgt example4 Enter number of
rows(-1 to end) 5 0 stars 1 stars 2
stars 3 stars 4 stars Please enter an
integer (-1 to end) -1 bvelez_at_amadeus gtgt
shell
9InputStream extraction operator
returns an input stream
cin gtgt variable
stream extraction operator
input stream
argument expression