This course provides an introduction to problem solving and programming using the C++ programming language. The topics include:Basic programming notions. Control flow, variables and assignments statements, conditional execution, looping, function calls including recursion. Arrays and structures. Elementary aspects of classes. Heap memory.Program design. How human beings solve problems manually. Strategies for translating manual strategies to computer programs. Organizing large programs into units such as functions and classes. Introduction to assertions and invariants.Programming applications. Arithmetic on polynomials, matrices. Root finding. Sorting and searching. Design of editors and simulators, including graphical editors. Elementary animation. A rudimentary graphics system will be discussed.Standard Library of C++. The string, vector and map classes.INTENDED AUDIENCE:First and second year students in degree programs including Engineering and Science degree programsPRE-REQUISITES:Standard XII in the Science streamINDUSTRY SUPPORT:Basic programming is of value to all. C++ allows you to design very fast programs and access low level machine features, but at the same time its libraries provide a very high level programming model. It can be considered a modern, safer version of the C language
Week 1:Introduction to computers using graphics. Notions of program organization, control flow. Introduction to a repeat macro statement and its use for drawing interesting pictures.Basics of computer hardware and how numbers and other information are represented and processed on computers.Week 2:Basic data types. Variables. Assignment statement. Introduction to program design using examples such as summing infinite series. Introduction to coordinate based graphics and elementary animation. The repeat macro is used for looping.Week 3-4: Statements of C++ for conditional execution and looping. Applications such as computing mathematical functions, root finding.Week 5:Functions. Parameter passing. Pointers and references. Recursion basics.Week 6:Recursive algorithms and recursive drawings. Breaking larger programs into functions. Passing functions as arguments to other functions.Week 7:Arrays. Basic array processing strategies including passing arrays to functions. Pointers. Applications illustrating use of arrays to store sets and sequences. Iterating over pairs of objects from an array. Selection sort.Week 8:Use of arrays to represent textual data. Multidimensional arrays. Command line arguments. Binary search. Mergesort.Week 9:Structures. Pointers with structures. Structure examples. Basics of classes: member functions, constructors, operator overloading and access control.Week 10:Dynamic memory allocation. Basic mechanisms and pitfalls. Design of a "String" class that has automated memory management. Copy constructors and destructors. Introduction to the standard library.Week 11-12: Use of the standard library in designing programs. Design of medium size programs. A miniature program for marks and ranks display. A program for gravitational simulation. A program for designing and solving resistive circuits with a graphical user interface.