CSCI200S04

Introduction to C++

 

Week 1

 

Class 1: Chapter 1 ¾ C++ Overview and Software Development (2-18)

1.1 What is C and What is C++ (6-10)

1.2 What Do You Mean by Object-Oriented? (10-12)

1.3 Structured Design Versus Object-Oriented Design (12-15)

1.4 Software Construction Techniques An Overview (16)

1.5 Troubleshooting (17)

2. INTRODUCTION to the Visual Studio C++ Environment

¾ Opening a Workspace and Creating a simple program: "Hello World"

//Hello world program ¾ example of a comment

#include <iostream> //preprocessor statement to include file with cout

using namespace std;

int main() //header for main

{ //left curly brace opens body of main function

  cout<<"hello world! \n"; //output hello world note \n, a new line

  return 0; //this statement returns an int and signals end of pgm

} //closing curly brace closes body of main function

 

Assignment:

1. Read Chapter 1: Focal Points ¾ Johnston's Rules for Programmers (6)

¾ go through and focus on bold faced terms like: source code, compiler, linker, portable language (8), functions, standardized libraries, object-oriented programming (10), C++ class, object ¾ distinction between Structured Programming and Object-Oriented Programming (presented as a difference in design approach) see Tables 1-3 and 1-4 (15).  Focus especially on Table 1-5 Don'ts and Do's for Programmers.

2. NOTE: Be prepared for a multiple-choice quiz on definitions and concepts next time.

3. Read ahead in Chapter 2 we will be doing Lab 2.1 in the next class.

 

Class 2: Getting Started: Data Types, Variables, Operators, Arithmetic, and Simple I/O (20-68)

            2.1 Programming Fundamentals (21- 44)

                        ¾ algorithm design, 6-steps to programming success (24), practice imagining an algorithm, Rule of Thirds: 1) specs, requirements, planning the user interface, and creating algorithms and test plans, 2) coding and testing, 3) system integration and testing.

            2.2 Terminology and Project Construction

            2.3 General Format of a C++ Program ¾ //comments, Preprocessor Directives, The Main Function (Function Header, Function Body)¾ we saw these in Hello World. (cout << output statement and cin >> input statement)

            2.4 Programs and Data: Balls and Sticks

            2.5 Data Types in C++ ¾ data types char //character data ex. 'a' using single quotes, float|double //five digit or ten digit numeric precision numbers, int //integer (whole numbers)

            2.6 Variable Declaration in C++ (43) ¾ to declare a variable in C++ you using the following syntax: data_type variable_name; ¾ variable names contains letters {A..Z, a..z} digits {0..9} or underscores _ ¾ case sensitive.  1st character much be a letter or an underscore (generally avoid using underscore first since this is commonly reserved for system variables)

DO PROGRAM 2.1 (Start in class, if you can't finish in class work on it and turn it in next time)

Assignment:

1. Read Chapter 2 focusing on math with integers and doubles since our next class will be working on Lab 2.2 which explores mathematical operations.

2. Finish Lab 2.1 to be turned in next time

 

Class 3 Chapter 2 sections (end of section 2.6, page 44 to end of chapter page 67)

¾ Declaring Variables in C++ 3 places 1) inside a function, 2) outside a function, and 3) in a function header line.  Where variables are Declared, determines where they can be seen, called the SCOPE of the variable.

            2.7 Operators in C++ ¾ primary operators (table 2-7 pg 46)

            Primary () [] . -> Arithmetic * / % + - Assignment = all Left to Right except = which is right to left.  Math Library #include <math.h> Increment/Decrement Operators ++ --  Accumulation Operators (57)

            2.8 Miscellaneous Topics: #define macros, const for defining constands and casting to convert variables from one type to another.

            2.9 Keyboard Input cin >> and Screen Output cout <<

Assignment:

1. Review Chapter 2 especially in light of the Lab program, Lab 2.2

2. Finish Lab 2.2 to be turned in next time is you did not complete it in class.