C++ Programming

Examples and exercises (from old course)

You can download the examples and run them on your PC.

topic pages examples exercises
overview over C++ 13-30 my first C++ program
square function
winter sports
constants, variables, operators 40-60 parallel resistors ASCII table
branches and loops 66-89 for loop and if statements
different kinds of loops
infinite loops
find mean
find precision
Newton-Raphson iteration
switch statement 76-80 nested if's versus switch animal insurance
goto statement 87 goto example  
arrays 92-97, 106-113 polynomial pupils' heights
strings 97-106 string functions pocket calculator
array of strings 113-117 boxers 1 political oracle (English)
politisk orakel (Danish)
array of string pointers 133-136 boxers 2
2-dimensional arrays 106 multiply matrix by scalar matrix operations
pointers 120-133, 136 loops with pointers word replacement
functions 144-159,164-172 square numerical integration
pointer parameters 178-180   equations
reference parameters 181-184  
various operators 221-229, 240 gray-code conversion bit manipulation
prime numbers
structures 242-257   telephone directory
classes 276-293, 301-304 random number generator
waiting list 1
ohm's law
pendulum
parabola
passing structure to function   1: passing by copying
2: passing through pointer
3: making the function a member
 
files 468-469, 483-485, 488-503   music 2
       
special topics
syntax notes   music
multi-module projects      
       
       
advanced topics not on first semester syllabus
type casting 61-62 type conversion
pointer conversion
 
conditional compilation      
new and delete 232-237 examples with new and delete
waiting list 2
 
formatted input/output      
inheritance 371 lotto coupon  
member pointers      
templates 421, 565 template for sorting  
function overloading 191 power function  
constructor overloading 310 overloading constructor  
operator overloading      
linked lists   waiting list 3  
       
differences between C and C++      

Page numbers refer to: Schildt, H.: C++ from the ground up, second edition, Osborne/McGraw-Hill 1998.

Examples from the book:

introduction chapter 2 chapter 3 chapter 4 chapter 5 chapter 6
chapter 7 chapter 8 chapter 9 chapter 10 chapter 11 chapter 12
chapter 13 chapter 14 chapter 15 chapter 16 chapter 17 chapter 18
chapter 19 chapter 20 chapter 21 chapter 22 appendix

Back to the Electronic Department Back to Engineering College of Copenhagen