PHY225
From Programming In C
- Topic 1 Introduction To Programming
Introduction to programming, what is a computer program, compilation etc basic C program, syntax rules, variables, naming variables, the printf statement
Exercise: Hello, World!
Exercise: Large letter
- Topic 2 Data types, basic arithmetic
Data types, assignment statements, operators, operator precedence
Exercise: Real roots of a quadratic equation
Exercise: Volume converter
- Topic 3 Control: decisions and looping
Use of the if, while, switch and for statements
Exercise: Hello, world! revisited
Exercise: Factorial
Exercise: Quadratic roots revisited
Techniques for planning and writing an algorithm as a C program, use of flow diagrams, step-by-step solutions to two past assessments
Exercise: Day of week
Exercise: Newton-Raphson method
- Topic 5 Functions
Function definitions, passing arguments to functions, returning values from functions, math.h library
Exercise: Replacement pow() function
Exercise: Simple sort function
- Topic 6 File I-O, formatted I-O
Input file handling, output file handling, multiple streams, use of printf to format output, more on scanf
Exercise: Cartesian to polar conversion (Vectors Data File)
Exercise: Student database (Students Database File)
- Topic 7 Arrays, dynamic array allocation
1 dimensional arrays, multidimensional arrays, arrays as function variables, dynamic array allocation
Exercise: Matrix multiplication
Exercise: Pascal's triangle
- Topic 8 Character strings, Structures
Character strings and string operators. Definition of structures and their use, arrays of structures, passing a structure to a function, arrays inside structures.
Exercise: Full name
Exercise: Planets in the Solar System (Planets Data File)
- Appendix Bubble sort algorithm
A simple algorithm for sorting
