EE 102 Sample Programs for Y. Daniel Liang textbook
Examples are added as course progresses. Examples are
improved or expanded during the semester to reflect outcomes of in class
discussion or deficiencies indicated be the corresponding exams. Actual examples
discussed in class may be slightly different but still cover the same
material.
If you have problems with printing of some programs
due to long lines switch to landscape page orientation.
-
First Programs, Data Types
- Sphere example - the first program we wrote - the very idea what a simple program is
- Sphere example - the first program we wrote - cin, cout, simple calculations
- Import "features" from the stadard libraries
-
Data types, variable declaration and exporessions (Chapters 2 through 3)
-
Selection with if, if-else, and switch-case
-
Examples how to format printouts
-
Repetition with while, do-while, and for loops
-
Functions
-
Arrays
-
2D Arrays
-
Introduction to Pointers
-
C-style Strings
-
Recursive functions
-
Files
- The idea of a class data type
- More about cin and cout
- Reading from a text file
- More file processing, writing to a text file
- Processing numerical data from a text file
-
Error handling with exceptions
- A triangle function case study
Source code listings were prepared using Code2HTML, courtesy of Peter Palfrader.