YOU ARE DOWNLOADING DOCUMENT

Please tick the box to continue:

Transcript
Page 1: Alexandria University Faculty of Science Computer Science Department Introduction to Programming (CS 102) C++ Programminhg.

Alexandria UniversityFaculty of Science

Computer Science Department

Introduction to Programming (CS 102)

C++ Programminhg

Page 2: Alexandria University Faculty of Science Computer Science Department Introduction to Programming (CS 102) C++ Programminhg.

Course Goals

Introduce General concepts of Programming

Begin to Think Like a Programmer

Start Programming With C++ (a powerful, widely-used programming language)

Become Junior C++ Programmer

Page 3: Alexandria University Faculty of Science Computer Science Department Introduction to Programming (CS 102) C++ Programminhg.

Course Outline:

3

• Introduction to Programming and problem solving.• Program structure and simple program.• Data types• Assignment statements• Input / output operations• Arithmetic operations• Logical operations • Conditional and selection control statements• Loops • Functions (call by value / reference)• Arrays ( 1D and 2D)

Page 4: Alexandria University Faculty of Science Computer Science Department Introduction to Programming (CS 102) C++ Programminhg.

Course grading system

Week # Marks Type

7 20 Exam Written

12 10 Exam Practical

7-13 10 Exam Oral / Assignments

14 60 Exam Final

4

Page 5: Alexandria University Faculty of Science Computer Science Department Introduction to Programming (CS 102) C++ Programminhg.

Course textbook• C How To Program 7/e

by:Paul Deitel & Harvey Deitel

5

COURSE LECURES/ASSIGNMENTS PDF copy on terminals in lab. Printed copy in copy centers. URL:https://www.alexu.edu.eg

Page 6: Alexandria University Faculty of Science Computer Science Department Introduction to Programming (CS 102) C++ Programminhg.

Lecture 1

Overview of Computer, Programming and Problem Solving

6

Page 7: Alexandria University Faculty of Science Computer Science Department Introduction to Programming (CS 102) C++ Programminhg.

The Program Development Life Cycle

• Creating new programs is called program development.• Creating successful applications requires planning• Computer professionals need to develop new or modified applications from time to time• The process associated with creating successful applications programs is called the program development life cycle (PDLC).

Page 8: Alexandria University Faculty of Science Computer Science Department Introduction to Programming (CS 102) C++ Programminhg.

The Program Development Life Cycle

Page 9: Alexandria University Faculty of Science Computer Science Department Introduction to Programming (CS 102) C++ Programminhg.

1. Problem Analysis • During analysis, a systems analyst and

programmer: – review specifications, and – talk with users to fully understand what the software

should do.

• Documentation consists of: – program specifications, – timetable, – which language will be used, – how the program will be tested, and – what documentation is required.

Page 10: Alexandria University Faculty of Science Computer Science Department Introduction to Programming (CS 102) C++ Programminhg.

2. Program Design

• Program design: stage where program specifications are expanded into a complete design of the new program.

• Structured programming and object-oriented programming are two of the most significant approaches to the design process.

Page 11: Alexandria University Faculty of Science Computer Science Department Introduction to Programming (CS 102) C++ Programminhg.

Program Design: Program Design Tools

Program design tools are planning tools.• Structure charts

• Program flowcharts

• Pseudocode

• Data modeling

Page 12: Alexandria University Faculty of Science Computer Science Department Introduction to Programming (CS 102) C++ Programminhg.

Structure Charts

• Structure charts depict the: – overall organization of a program, and – how the modules of a program are defined and – how they connect to each other hierarchically.

• Program modules should be arranged hierarchically in a top-down fashion• Why?? So that their relationship to each other is apparent.

Page 13: Alexandria University Faculty of Science Computer Science Department Introduction to Programming (CS 102) C++ Programminhg.
Page 14: Alexandria University Faculty of Science Computer Science Department Introduction to Programming (CS 102) C++ Programminhg.

Flowcharts• Use geometric symbols and familiar relational operators to provide a graphic display of the sequence of steps involved in a program

• Different symbols are used to represent different actions such as

− Start/stop−Decision−Input/output−Processing−Looping symbols

Page 15: Alexandria University Faculty of Science Computer Science Department Introduction to Programming (CS 102) C++ Programminhg.
Page 16: Alexandria University Faculty of Science Computer Science Department Introduction to Programming (CS 102) C++ Programminhg.
Page 17: Alexandria University Faculty of Science Computer Science Department Introduction to Programming (CS 102) C++ Programminhg.
Page 18: Alexandria University Faculty of Science Computer Science Department Introduction to Programming (CS 102) C++ Programminhg.

Pseudocode• Uses English-like statements in place of the graphic symbols of the flowchart.

• Unlike a flowchart, pseudocode is easy to modify and can be embedded into a program as comments.

• No standard set of rules exists for writing pseudocode, although a number of conventions have been developed.

Page 19: Alexandria University Faculty of Science Computer Science Department Introduction to Programming (CS 102) C++ Programminhg.
Page 20: Alexandria University Faculty of Science Computer Science Department Introduction to Programming (CS 102) C++ Programminhg.

Program Design: Program Design Tools

Data modeling is a technique used to illustrate the data in an application and is frequently used with object-oriented programming.

In a data model, the objects in the program are identified, along with their variables and class.

Page 21: Alexandria University Faculty of Science Computer Science Department Introduction to Programming (CS 102) C++ Programminhg.

Program Design: Good Program Design

    Good program design is essential; it can save time and it produces a better end result. Some principles of good program design are:

• Be specific

• One-entry-point, one-exit-point rule

• No infinite loops

• Documentation during program design includes all the design specifications

Page 22: Alexandria University Faculty of Science Computer Science Department Introduction to Programming (CS 102) C++ Programminhg.
Page 23: Alexandria University Faculty of Science Computer Science Department Introduction to Programming (CS 102) C++ Programminhg.

3. Program Coding • Coding: actual process of creating the

program in a programming language. – Programming language must be chosen.– Coding standards should be adhered to.– Make use of reusable code and data dictionaries.– Translate coded programs into executable code.

• Documentation results in finished source code.

Page 24: Alexandria University Faculty of Science Computer Science Department Introduction to Programming (CS 102) C++ Programminhg.
Page 25: Alexandria University Faculty of Science Computer Science Department Introduction to Programming (CS 102) C++ Programminhg.

3. Program Coding cont’d• The coded program is referred to as source code.

To be executed, the program is converted by the computer to object code using a special program.

• A compiler translates the entire program into machine language before executing it. The program then doesn’t need to be recompiled until it is modified.

• An interpreter translates program statements one at a time. Interpreters are helpful during the debugging stage, but are slower during execution of the finished program.

• An assembler converts assembly-language statements into machine language.

Page 26: Alexandria University Faculty of Science Computer Science Department Introduction to Programming (CS 102) C++ Programminhg.
Page 27: Alexandria University Faculty of Science Computer Science Department Introduction to Programming (CS 102) C++ Programminhg.

4. Program Debugging and Testing

• Debugging: process of making sure a program is free of errors or bugs.– Preliminary bugging often finds syntax or logic

errors. – Testing can consist of alpha or beta testing.

• Documentation includes a copy of the finished program code, plus test data and results.

Page 28: Alexandria University Faculty of Science Computer Science Department Introduction to Programming (CS 102) C++ Programminhg.

4. Program Debugging and Testing cont’d

• Preliminary debugging begins after the program has been entered into the computer system.

• Rarely is a program error-free the first time it runs.

• Two common types of errors are syntax errors and logic errors:− A syntax error occurs when the programmer has not

followed the rules of the language.

− A logic error, or execution-time error, results when the command syntax is correct but the program is producing incorrect results.

Page 29: Alexandria University Faculty of Science Computer Science Department Introduction to Programming (CS 102) C++ Programminhg.

5. Program Maintenance

• Program maintenance: process of updating software so that it continues to be useful. – A costly process, but can be used to extend the

life of a program.

• Documentation consists of amended program package reflecting what problems occurred and what program changes were made.

Page 30: Alexandria University Faculty of Science Computer Science Department Introduction to Programming (CS 102) C++ Programminhg.

What Is a Programming Language?

A programming language is a set of rules used to write instructions to the computer.

Page 31: Alexandria University Faculty of Science Computer Science Department Introduction to Programming (CS 102) C++ Programminhg.

Categories of Programming Languages

• Low-level languages

• High-level languages

• Fourth-generation languages (4GLs)

• Natural and visual languages

Page 32: Alexandria University Faculty of Science Computer Science Department Introduction to Programming (CS 102) C++ Programminhg.

Machine and Assembly Languages

• Machine and assembly languages are called low-level languages

• Programmers who code in them must write instructions at the finest level of detail, the base level of the hardware

• Virtually no one writes machine-language programs anymore

• All programs must be translated by a language translator into machine language before they are executed

• Assembly languages are fast and consume little storage when compared with higher-level languages, but take longer to write and maintain

Page 33: Alexandria University Faculty of Science Computer Science Department Introduction to Programming (CS 102) C++ Programminhg.

High-Level Languages

 High-level languages differ from their low-level predecessors in that they require less coding detail and make programs easier to write.

• Programs written in a high-level language (BASIC, COBOL, Pascal, C, etc.) need to be translated into machine language before they can be executed.

Page 34: Alexandria University Faculty of Science Computer Science Department Introduction to Programming (CS 102) C++ Programminhg.

Fourth Generation Languages (4GL)

• Very-high-level languages that are much easier to use than the high-level languages

• They are declarative rather than procedural languages.

• For instance, to draw a bar chart in a procedural language, you must tell the computer how to draw bars and where to place them.

• In a declarative language, you may be able to just point to the data you want graphed, click several menu choices, and you’re in business.

• Fourth-generation languages are commonly used to access databases (query languages).

Page 35: Alexandria University Faculty of Science Computer Science Department Introduction to Programming (CS 102) C++ Programminhg.

Popular Programming Languages

• FORTRAN

• COBOL

• Pascal

BASIC and Visual Basic

C, C++, AND C#

Java

Page 36: Alexandria University Faculty of Science Computer Science Department Introduction to Programming (CS 102) C++ Programminhg.
Page 37: Alexandria University Faculty of Science Computer Science Department Introduction to Programming (CS 102) C++ Programminhg.

Markup Languages

• Markup languages use symbols or tags to describe what a document should look like when displayed.

– HTML (Hypertext Markup Language)– Dynamic HTML– XML (extensible markup language) – XHTML (extensible Hypertext Markup Language) – WML (Wireless Markup Language )

Page 38: Alexandria University Faculty of Science Computer Science Department Introduction to Programming (CS 102) C++ Programminhg.
Page 39: Alexandria University Faculty of Science Computer Science Department Introduction to Programming (CS 102) C++ Programminhg.

Scripting Languages

• Scripting languages are used to build program instructions into Web pages, usually to add dynamic content.

– JavaScript

– VBScript

– Perl

Page 40: Alexandria University Faculty of Science Computer Science Department Introduction to Programming (CS 102) C++ Programminhg.

Related Documents