CIS 67: Some Simple C and C++ Programs
- The Hello program: C, C++
- Computing powers of 2: C, C++
- Printing Large Block Letters: C,
C++
- Adding two integers
- Adding n integers
- Adding a sequence of positive integers
- Computing value of a collection of coins
- Computing the factorial of a number
- Determining if a number is a prime
- Finding all the proper factors of a number
- Raising a number to some power
- What are in C the values of TRUE and FALSE?
- Some casts and conversions
- Printing a Stair
- Printing a Square
- Printing a Triangle
- Printing a Diamond
- Printing a Circle
- Printing a Chess Board
- Numeric value of printable characters
- Computing the GCD of two numbers using the Euclidean
Algorithm
- Computing Fibonacci numbers
- Some simple functions
- More simple functions
- Passing parameters by value, pointer, and
reference
- More about parameters, their addresses and
values
- Finding the smallest of three numbers, sorting three
numbers
- Simple example on scope rules
- Another example on scope rules
- Playing games with characters
- Operations on arrays
- Simple uses of arrays
- Reading, writing, reversing an integer array
- Playing with two-dimensional array
- Transposing an array,
again, and
again
- Factorial as a recursive function
- Starting with Strings
- More strings
- Two functions on strings
- Beware of integer overflow
- Beware of unsigned integers
- Beware of postincrements
- Beware of Round-off errors
- Converting words to Pig Latin
- Using assert
- Asserting and debugging
- Computing the square root of a number
- Files and C strings [same using strings]
- Reading lines from input and echoeing them to output [C++]
- Reading from cin: get, getline, ignore, putback, ..
- More reading from cin
- Copying a file character by character
- Copying a file line by line
- Simple uses of IO Manipulators
- Using enumerations in
C
and in C++
- Reading and writing enumeration literals
- Simple do's and don'ts of structures,
done in a second way, and
third way
- Passing a structure by value and passing it by
reference
- Printing out the command line parameters
- Copying a file with student records - using ws and ignore
- Reading and writing to a file an array of structures
- Reading and writing to a file an array of pointers to structures
- Reading and writing to a file a dynamic array of pointers to structures
- Reading and Writing to Strings
- Rotating an array's content k positions to the left
- Sorting an array of integers with Selection Sort
- Sorting an array of integers with Insertion Sort
- Sorting an array of integers with Bubble Sort
- Sorting an array of integers with Quick Sort
- Merging two sorted files into a third
- Finding
the k-th smallest element of a set
- Reading an array and doing linear searches on it
- Reading an array and doing binary searches on it
-
A struct Student,
a class Student, and
another class Student
- Some simple class constructors
- A stack class: variation on Prof.Lafollette's
example
- A Point class, copy constructor, copy assignment operator, a destructor
-
The Rational class from Cohoon-Davidson
- A variation on the Rational class
- A class to access a one-dimensional array as
a two-dimensional array
- Morse encoding and decoding using a static class
- A class Stripe for printing block letters consecutively on the same rows
- Various C features: __DATE__, sizeof, conditional expressions, ..
- Various C++ features: __DATE__, sizeof, conditional expressions, ..
- Addresses and values of variables
- Reading lines from input and echoeing them to output [C]
- Starting with strings
- Reading a line from input
- Compacting a string
- Various counts on a text file
- Arrays and pointers: pointer arithmetic
- Silly recursion: Print an array recursively
- Selection Sort, decomposed into
multiple files [see
discussion]
- Merging sorted sequences of integers
- Merging two sorted files of strings
- Sorting and merging sequences of student records
- Playing the Towers of Hanoi Game
- Dynamic Storage: A Queue of integers
- Dynamic Storage: A Queue of integers as a class
- Dynamic Storage: A Stack of Characters
- Dynamic Storage: A Stack of Characters as a Class
- Reading into a string a single token per line
- Reading tokens, comparing names
- A
C program to remove those ugly CONTROL-M s , and the
same in C++
- Testing two hash functions
- Reading and writing to a file a list of structures
- Generic FIFO without ownership
of nodes and its driver
- Reading and writing to a file a
list of structures using a queue ADT
-
Sorting in a problem with files, structures, and pointers
- Create a binary file from
a text file and then
read from it
- Testing a random
number generator using a histogram class
- Printing all distinct decompositions of an integer n into its addends
- Finding the Cantor expansion of a number
- Playing a game on a triangular board