Topic: C++ Programming language


Objective
Topic
Resources
Remarks

Students will
· Understand the basic syntax of C++;
· Understand the types of flow controls
· Be able to write simple codes involving arithmetic computations, logical expressions and conditionals
· Be able to write more complex coding using string, loops and array
Course content overview

The contents are:
· Introduction to programming & compiler, program structure
· Variables & assignment statements
· Input and output
· Data types and expressions
· Arithmetic, Relational & Logical operators
· Control structure: if & nested if,
· Loop mechanisms: do, while, for and nested loops
· Arrays ( 1 and 2 dimensional )
Computer lab

Software:
Dev C++
Assessment:
· Assignment ( Simple programming )
· Project ( More challenging programming)
· Quick Tests
· Term Test
Wk1
Students will understand and know
· How programming languages work
· How to down load Dev C++ compiler
· How to use Dev C++ to create, edit, debug, run and save C++ program
· Basic Syntax of C++
· Some C++ websites for self learning
Introduction to C++ programming language, what is it used for and how it works

· History of C and C++
· Basic Syntax of C++
· Program Layout
· Compiler Directive
· Library
· Comments
· Statement termination
· main() function
· Case Sensitive
· Statement and block
· Free down load site for Dev C++, learn how to download and install
· Dev C++ Integrated Development Environment (IDE)
· Create, Compile, Debug, Run and Save program
· Open/Edit an existing C++ program
Computer lab

Websites:
http://cplus.about.com/library/blcplustut.htm

www.cprogramming.com/tutorial.html

Dev C++
Download:

http://csjava.occ.cccd.edu/~gilberts/devcpp5/
Introduction lesson

Assignment #1:
Program debugging

Quick Test #1
Understanding of C++ syntax
Wk2
Students will learn:
· How to use variable to store data
· Use of constants in C++ program
· Input data from keyboard
· Display output on the screen
· How to write a C++ program which will only handle input/output and simple arithmetical operation
Basic programming elements of C++

· Purpose of variables
· Rules for naming a variable (neither starting with digit nor a keyword)
· Data types
· Declare variable of certain data type
· Declare a constant of certain data type (using #define directive or keyword const)
· Enumerations ( enum )The library <iostream> for input/output purposeThe input object cin and the input operator >>
· The output object cout and the output operator <<
· The endl or escape code ‘\n’ for end of line character
· Input/output multiple values
· The operators +, -, *, / and %
· Priority of operators when evaluate an arithmetic expression (use of brackets)
Computer lab

C++ compiler
Hands On 1:
To find the area of a square with a side.

Hands On 2:
To find the number of sweets and the remainder when distributing a given number of sweets to a given number of boys.

Project #1:
Sum of digits for a 3-digit integer
Wk3
Students will learn:
· The syntax of simple if statement (without else)
· The syntax of if statement and else statement
· Relational and logical operators
· The Boolean data type
· The syntax of nested if statements and understand its logic
The if statement

· Syntax of simple if statement: if ( Boolean expression ) { statements }
· Syntax of if statement with else:
if ( Boolean expression ) { statements } else { statements }
· True and false values: 1 and 0
· Relational operators <, <=, ==, >, >= and !=
· Logical operators &&,
and !
· Syntax of nested if statement: if (Boolean expression) { statements} else if (Boolean expression) { statements} ………. Else { statements}
Computer lab

C++ compiler
Assignment #2:
Grading of a test marks

Quick Test #2:
About if syntax and how it works


Project #2:
Allocation of classes base on results of 3 subjects ( require the use of complex if statement)
Wk4
Students will learn

· How to define a string
· Read a string
· String functions
· The different between string and character
String and its functions

  • Using char to define a string
  • String as an array of characters
  • How characters are store in string
  • The <string.h> header
  • String functions: strlen, strcmp, strupr, strlwr
Computer lab

C++ compiler
Assignment #3:
To find the length of a word and check whether it is upper case or lower case

Quick Test #3

Project #3:
To determine whether a phrase is a sentence or not.
Wk5
Students will learn:

  • What is a C++ function
  • The purpose of using function in programming
  • The syntax of function
  • Void function
  • The built in function, the random number generator
Function and built-in function, the random numbers generator

  • The general syntax of a function, its value type, name and parameters
  • The return statement associated with the function
  • Using void to define a function which does not require to return a value
  • Rand() and srand() function
  • Use srand(time(0)) to generate an unpredictable sequence of numbers
  • Generate integer between a range of integer a and b, a+rand()%(b-a+1)
Computer lab

C++ compiler
Assignment #4:
Using function method to find the max and the min of 3 integers.


Project #4:
Use random number generator to generate marks for six subjects and using function to find the grades of of the subjects and calculate the MSG.
Wk6
To test the understanding of the following:

· Basic C++ programming syntax
· The if statement
· The string and some basic string functions
Term Test on:
Programming syntax, if statement and string

Format:
  • Multiple choice
  • True or False
  • Fill in the blanks
  • Practical ( programming )
Computer lab

C++ compiler

Test question papers

Wk7
Students will learn:
· Situations when looping is required in programming to solve certain problems
· The syntax of while statement and how it works
· The syntax of do statement and how it works
· The difference between while and do statement
Loop statements ( do and while )
· The Syntax of while statement
while (tested condition is satisfied) {
block of code
}
· The Syntax of do statement
do {
block of code
} while (condition is satisfied)
· Example: Guessing number program
Note the difference between while and do loop, give examples for the use of each one when it is appropriate
Computer lab

C++ compiler
Assignment #5:
Find common factors, HCF and LCM of two integers

Project #5:
Express the prime factorization of an integer.
Wk8
Student will learn:
· The for loop syntax
· The initialisation
· The test condition
· The actions
· The body part of the for loop
· How to define an array
· Access element of an array using index
· Simple array processing
The for loop statement and one-dimensional array
· The syntax of for loop
for (initializations;test conditions;actions)
{
block of code
}
  • Examples of for loop programs
  • Nested loops
  • One dimension array declaration
  • Storing and accessing data in the array, use of index
Computer lab

C++ compiler
Assignment #6:
Marks processing ( using array), using random number function to generate marks for students in a class, process the marks to find the highest, lowest, average, number of grade A and above the average mark.
Wk9
Students will learn:

  • How to define a 2-dimensional array
  • Using of nested loops to access items in the array
Nested for loops and two dimensional array

  • Define a two dimensional array
  • The indexes of the row and column of the two dimensional array
  • Two level nested loops
  • Storing and accessing elements in the two dimensional array
Computer lab

C++ compiler
Project #6:
Tic-tac-toc game















Assessment Components:

1. There will be no End Of Year examination, assessment will be based on the following:

Assessment Methods
Weighting
Remarks
Type 1 - Term Tests
30%
Consists of several small tests and a major term test
Practical hands-On (Programming assignments and projects )
70%
Marks (base 100) will be awarded for each of the Term 1 to Term 3.

2. Marks for programming assignments & projects

Students will be given about 5 programming assignments (simple) and 5 programming projects( more advance) and must be completed during the lesson period. Six to ten marks will be awarded for correct programming results, the earlier submission will score higher marks. A rough marks distribution can be as follow:

· 1st 10% of students completed (or those who can complete within a minimum required time ) will get 10 marks
· Next 15% of students completed will get 9 marks
· Next 30% of students completed will get 8 marks
· Next 30% of students completed will get 7 marks
· Next 15% of students completed will get 6 marks
· Partially Correct: 5 marks
· Did not attempt: 0 mark

The average mark is computed by total marks divided by number of assignments/projects, say M.
Practical hands-on mark (base 100) will be 10xM (Round up to integer).