cis-165 c++ programming i cis-165 c++ programming i bergen community college prof. faisal aljamal

30
CIS-165 C++ Programming I Bergen Community College Prof. Faisal Aljamal

Upload: ross-powers

Post on 03-Jan-2016

223 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CIS-165 C++ Programming I CIS-165 C++ Programming I Bergen Community College Prof. Faisal Aljamal

CIS-165 C++ Programming I

Bergen Community College

Prof. Faisal Aljamal

Page 2: CIS-165 C++ Programming I CIS-165 C++ Programming I Bergen Community College Prof. Faisal Aljamal

Course Content

1. Introduction to Hardware and Software.

2. Program development.

3. Interaction with the Computer system.

4. Identifier Tables

5. Program Structure: heading Section and Declaration section

6. Program Structure : Input Section.

Page 3: CIS-165 C++ Programming I CIS-165 C++ Programming I Bergen Community College Prof. Faisal Aljamal

Course Content7. Program Structure: Output Section.

8. Program Structure: Process Section.

9. Formatted Output.

10. Conditions and Boolean Expressions.

11. Selection Control Structures.

12. Repetitions Control Structure (do-While and for statements.

13. Repetitions Control Structure (While Statement).

Page 4: CIS-165 C++ Programming I CIS-165 C++ Programming I Bergen Community College Prof. Faisal Aljamal

Course Content

14. Structured Data Types (One-dimensional Arrays)

15. Processing One dimensional Arrays.

Page 5: CIS-165 C++ Programming I CIS-165 C++ Programming I Bergen Community College Prof. Faisal Aljamal

1. Introduction to Hardware and Software.

Hardware Components of a computer. Systems software and applications

software. Programming languages.

Page 6: CIS-165 C++ Programming I CIS-165 C++ Programming I Bergen Community College Prof. Faisal Aljamal

2. Program development. Overview of the program development Process. Problem Specification. Algorithm design and presentation. Source code, object code and the Compiler.. Syntax Errors, run time errors, logic.

Page 7: CIS-165 C++ Programming I CIS-165 C++ Programming I Bergen Community College Prof. Faisal Aljamal

3. Interaction with the Computer system.

Formatting a disk. Sign on and sign off procedures. Creating, editing, and saving a source

code file. Compiling, debugging and executing a

program. Printing a text file.

Page 8: CIS-165 C++ Programming I CIS-165 C++ Programming I Bergen Community College Prof. Faisal Aljamal

4. Identifier Tables

Keywords, standard identifiers and programmer-defined identifiers.

Variables and symbolic constants. Standard scalar data types. String data type. Literal constants. Contents of an identifier table

Page 9: CIS-165 C++ Programming I CIS-165 C++ Programming I Bergen Community College Prof. Faisal Aljamal

5. Program Structure: heading Section and Declaration section

General Structure of a C++ program Heading section. Comment statement Declaration statement. typedef. The main() function.

Page 10: CIS-165 C++ Programming I CIS-165 C++ Programming I Bergen Community College Prof. Faisal Aljamal

6. Program Structure : Input Section.

System routines, the preprocessor and the Linker.

Streams and the iostream. Manipulators. String input.

Page 11: CIS-165 C++ Programming I CIS-165 C++ Programming I Bergen Community College Prof. Faisal Aljamal

7. Program Structure: Output Section.

Unformatted output. fstream library and file I/O. Writing a program output to a disk file.

Page 12: CIS-165 C++ Programming I CIS-165 C++ Programming I Bergen Community College Prof. Faisal Aljamal

8. Program Structure: Process Section.

Operator terminology. Arithmetic operators. Increment and decrement operators. Side effects and sequence points. Implicit and explicit type conversions. Assignment operator and assignment statement. String copy function Std Math. Library functions.

Page 13: CIS-165 C++ Programming I CIS-165 C++ Programming I Bergen Community College Prof. Faisal Aljamal

9. Formatted output.

Manipulators with arguments. ios format flags. Output design. Creating a program template.

Page 14: CIS-165 C++ Programming I CIS-165 C++ Programming I Bergen Community College Prof. Faisal Aljamal

10. Conditional and Boolean Expressions.

Simple conditions and compound conditions.

Relational, equality, negation and logical operators.

Precedence and associatively of operators.

String compare function. Representing conditions by Boolean

expressions

Page 15: CIS-165 C++ Programming I CIS-165 C++ Programming I Bergen Community College Prof. Faisal Aljamal

11. Selection control structure.

if statement and nested if statement . Compound statement. Conditional operator. Switch statement. Break statement. Program testing and debugging-

structured walk through.

Page 16: CIS-165 C++ Programming I CIS-165 C++ Programming I Bergen Community College Prof. Faisal Aljamal

12. Repetition Control Structures:

do while statement. Input validation. For statement. Table generation.

Page 17: CIS-165 C++ Programming I CIS-165 C++ Programming I Bergen Community College Prof. Faisal Aljamal

13. Repetition Control Structures

While statement. Continue statement. Program testing and debugging-

structured walk through.

Page 18: CIS-165 C++ Programming I CIS-165 C++ Programming I Bergen Community College Prof. Faisal Aljamal

14. Structured data Types: one D Arrays.

Terminology and storage. Declaration form – use of typedef. Array input. Array output

Page 19: CIS-165 C++ Programming I CIS-165 C++ Programming I Bergen Community College Prof. Faisal Aljamal

15. Processing One-dimensional Arrays

Mean component of an array. Maximum and Minimum component of

an array. Storing array component. Searching an array. Other fundamental array processing

algorithms.

Page 20: CIS-165 C++ Programming I CIS-165 C++ Programming I Bergen Community College Prof. Faisal Aljamal

Note !!

Slide one 1-15 demonstrated the general contents of the CIS-165 Course in “plain English”

What does that mean in C++ ??

Page 21: CIS-165 C++ Programming I CIS-165 C++ Programming I Bergen Community College Prof. Faisal Aljamal

C++ UP_FRONTNO Surprises !!

Data types:• integers, real (float), long, short, char, string.

Declaration:• int var1

• float var2

• Char z

• .

• .

Page 22: CIS-165 C++ Programming I CIS-165 C++ Programming I Bergen Community College Prof. Faisal Aljamal

C++

Library functions such as: sqrt( ), pow( ).

Input such as :cin >> , cin.getline( )

Output such as: cout <<

Formatted outputsetw( )

Page 23: CIS-165 C++ Programming I CIS-165 C++ Programming I Bergen Community College Prof. Faisal Aljamal

C++ Operators:

>, <, =, != … Logical :

and &&, or || Boolean (True and False) if else statement

if (x > y)

z=0;

else

z=1;

Page 24: CIS-165 C++ Programming I CIS-165 C++ Programming I Bergen Community College Prof. Faisal Aljamal

C++ Switch and case:

switch(var){

case 1:codes to execute.break;

case 2:codes to execute.break;

}

Page 25: CIS-165 C++ Programming I CIS-165 C++ Programming I Bergen Community College Prof. Faisal Aljamal

Do while

do {

stat1;

stat n;

} while (condition true);

Page 26: CIS-165 C++ Programming I CIS-165 C++ Programming I Bergen Community College Prof. Faisal Aljamal

While stat.

While (condition true)

{

stat 1;

stat n;

}

Page 27: CIS-165 C++ Programming I CIS-165 C++ Programming I Bergen Community College Prof. Faisal Aljamal

Input validation

if(cin.fail()) For stat.

For (i=0; I < 100; i++)

{

stat 1;

stat n;

}

Page 28: CIS-165 C++ Programming I CIS-165 C++ Programming I Bergen Community College Prof. Faisal Aljamal

One D Array

int MyArray[5]= {1,2, 4, 6,8}

Char My_Chr_Array [ ]={‘a’, ‘b’, ‘g’,’\0’}

typedeftypedef unsigned short int USHORT;

USHORT width, height, length;

Page 29: CIS-165 C++ Programming I CIS-165 C++ Programming I Bergen Community College Prof. Faisal Aljamal

Constants (also called literals)Defining constants with const:

const unsigned short int Stu_Per_Class =10; Defining constants in traditional way:

#define studentsPerClass = 10; Symbolic Const.

students = classes *15; Enumerated const:

enum Color {Red, Blue, White, Black};

Page 30: CIS-165 C++ Programming I CIS-165 C++ Programming I Bergen Community College Prof. Faisal Aljamal

White space

X= a + b;

Or as

X = a

+ b ;