Math 201-01 - Engineering Computer Programming

Examples from Class


Example 0 --- Our first C++ program - demonstrates endl and "\n"
Example 1 --- Simple program with two functions
Example 2 --- Illustrates loss of significance
Example 3 --- Double precision version of Example 2
Example 4 --- Another loss of significance example
Example 5 --- Illustrates the different types of constants
Example 6 --- Integer data types and sizeof operator
Example 7 --- Integer arithmetic
Example 8 --- Incrementing
Example 9 --- Boolean data type
Example 10 --- Character data type
Example 11 --- Floating-point data types
Example 12 --- Demonstrates cin, M_PI, pow(), and cout.precision()
Example 13 --- Demonstrates cin, const
Example 14 --- Demonstrates relational operators
Example 15 --- Demonstrates logical operators
Example 16 --- Demonstrates blocks and scope (Warning: Does not compile.)
Example 17 --- If statement
Example 18 --- If statement and a user-defined abs value function
Example 19 --- Another if statement example
Example 20 --- If else statement, Pythagorean theorem
Example 21 --- If else statement, srand(), and rand()
Example 22 --- Our first for loop
Example 23 --- For loop, triangular numbers
Example 24 --- For loop, harmonic numbers, log()
Example 25 --- While loop, triangular numbers, setw()
Example 26 --- While loop, average value
Example 27 --- Switch statement (optional)
Example 28 --- Switch statement (optional)
Example 29 --- Do statement
Example 30 --- Break statement, Newton's method
Example 31 --- Break and continue statements;
Example 32 --- Closer look at simple function
Example 33 --- Example 32 with conditional expression operator (optional)
Example 34 --- Example 32 with function in separate file (my_func1.h)
Bisection Method --- Easy version
Bisection Method - Savvy version
Example 35 --- Vector magnitude (norm()) with optional default arguments
Example 36 --- More with random numbers
Example 37 --- Functions calling other functions
Example 38 --- Recursion and the triangular numbers
Example 39 --- Overloading the norm() function
Monte Carlo Integration --- Our Monte Carlo program from class
Example 40 --- Address-of operator
Example 41 --- Dereference (indirection) operator
Example 42 --- Intro to pointers
Example 43 --- One-dimensional arrays
Example 44 --- Array initialization and some more format manipulators
Test Problem --- Here is the template for the Test 2 problem involving bitrev()
Example 45 --- Functions as arguments (simpson.h)
Example 46 --- Arrays as arguments
Example 47 --- Passing arguments by reference
Example 48 --- Intro to strings
Example 49 --- cin.eof()
Example 50 --- Intro to 2D arrays
Example 51 --- read_matrix() and prnt_matrix() functions
Example 52 --- Intro to function templates
Example 53 --- Another function template
Example 54 --- Matrix addition
matrix.h --- File for matrix read, write, and linear combination
Example 55 --- File input
Example 56 --- File input
Example 57 --- Reading to end-of-file
Example 58 --- File output
Example 59 --- File output with formatting
Example 60 --- File or keyboard input
Example 61 --- Sphere class Ex 1
Example 62 --- Sphere class Ex 2
Example 63 --- Sphere class Ex 3
Example 64 --- Sphere class Ex 4
Example 65 --- Sphere class Ex 5 (sphere1.h)
Example 66 --- Sphere class Ex 6 (sphere2.h)
Example 67 --- Sphere class Ex 7 (sphere3.h)
Example 68 --- Vector class Ex 1 (vec1.h)
Example 69 --- Vector class Ex 2 (vec2.h)
Example 70 --- Vector class Ex 3 (vec3.h)
Example 71 --- Vector class Ex 4 (vec4.h)
Example 72 --- Vector class Ex 5 (vec5.h)
Example 73 --- Vector class Ex 6 (vec6.h)
Example 74 --- Vector class Ex 7 (requires vec6.h)
Example 75 --- Vector class Ex 8 (requires vec6.h)