cc112 structured programming lecture 1 1 arab academy for science and technology and maritime...

19
CC112 Structured Programming Lecture 1 1 Arab Academy for Science and Technology and Maritime Transport College of Engineering and Technology Computer Engineering Department

Upload: kenneth-davidson

Post on 17-Jan-2016

219 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: CC112 Structured Programming Lecture 1 1 Arab Academy for Science and Technology and Maritime Transport College of Engineering and Technology Computer

CC112 Structured Programming

Lecture 1

1

Arab Academy for Science and Technology and Maritime Transport 

College of Engineering and Technology

Computer Engineering Department

Page 2: CC112 Structured Programming Lecture 1 1 Arab Academy for Science and Technology and Maritime Transport College of Engineering and Technology Computer

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 Programmer2

Page 3: CC112 Structured Programming Lecture 1 1 Arab Academy for Science and Technology and Maritime Transport College of Engineering and Technology Computer

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: CC112 Structured Programming Lecture 1 1 Arab Academy for Science and Technology and Maritime Transport College of Engineering and Technology Computer

COURSE GRADING SYSTEM

Week # Marks Marks assigned to

Exam Section

7 30 20-25 5-10

12 20 20 -

7-15 10 - 10

16 40 40 -

4

Page 5: CC112 Structured Programming Lecture 1 1 Arab Academy for Science and Technology and Maritime Transport College of Engineering and Technology Computer

COURSE TEXTBOOK C How To Program 7/e

by:Paul Deitel & Harvey Deitel

5

COURSE LECURES/ASSIGNMENTS PDF copy on terminals in lab (300 and 312). Printed copy in AAST copy centers. URL:https://www.dropbox.com/sh/kpnqizb5o

2yu6db/Mu4R_2qamo

Page 6: CC112 Structured Programming Lecture 1 1 Arab Academy for Science and Technology and Maritime Transport College of Engineering and Technology Computer

LECTURE 1

Overview of Computer, Programming and Problem Solving

6

Page 7: CC112 Structured Programming Lecture 1 1 Arab Academy for Science and Technology and Maritime Transport College of Engineering and Technology Computer

LECTURE OUTLINE

i. What is a Program?

ii. What is Programming?

iii. Programming Life-Cycle Phases

iv. Algorithm Basic Control Structures

v. Sample problem7

Page 8: CC112 Structured Programming Lecture 1 1 Arab Academy for Science and Technology and Maritime Transport College of Engineering and Technology Computer

i. WHAT IS PROGRAM?

Computers process data under the control of sets of instructions called computer programs.

These programs guide the computer through ordered actions specified by people called computer programmers.

The programs that run on a computer are referred to as software.

8

Page 9: CC112 Structured Programming Lecture 1 1 Arab Academy for Science and Technology and Maritime Transport College of Engineering and Technology Computer

ii. WHAT IS PROGRAMMING?

Find an algorithm to solve a problem.

Programmers take this algorithm to write a program using any programming language.

9

Given a well-defined problem:

Page 10: CC112 Structured Programming Lecture 1 1 Arab Academy for Science and Technology and Maritime Transport College of Engineering and Technology Computer

Analyze

•This involves identifying the data you have to work with it, the desired results, and any

additional requirements or constrains on the solution.

Design

•An algorithm is a step-by-step procedure for solving a problem in a finite amount of time.

Implement

•Each algorithm is converted into one or more steps in a programming language. This process is called PROGRAMMING.

10

iii. PROGRAMMING LIFE CYCLE PHASES

Page 11: CC112 Structured Programming Lecture 1 1 Arab Academy for Science and Technology and Maritime Transport College of Engineering and Technology Computer

Test and verif

y

•Run the program several times using different sets of data, making sure that it works correctly for every situation in the algorithm.

•if it does not work correctly, then you must find out what is wrong with your program or algorithm and fix it--this is called DEBUGGING.

Maintai

n and update

•maintenance begins when your program is put into use and accounts for the majority of effort on most programs.

•MODIFY the program to meet changing requirements or correct errors that show up in using it.

11

iii. PROGRAMMING LIFE CYCLE PHASES

Page 12: CC112 Structured Programming Lecture 1 1 Arab Academy for Science and Technology and Maritime Transport College of Engineering and Technology Computer

iv. ALGORITHM BASIC CONTROL STRUCTURES

12

a sequence is a series of statements that execute one after another.

Statement Statement Statement . . .

Page 13: CC112 Structured Programming Lecture 1 1 Arab Academy for Science and Technology and Maritime Transport College of Engineering and Technology Computer

13IF Condition THEN Statement1 ELSE Statement2

Statement1 Statement

Statement2

Condition . . .

True

False

iv. ALGORITHM BASIC CONTROL STRUCTURES

selection (branch) is used to execute different statements depending on certain conditions.

Page 14: CC112 Structured Programming Lecture 1 1 Arab Academy for Science and Technology and Maritime Transport College of Engineering and Technology Computer

14

Statement

Condition. . .

False

True

WHILE Condition Statement1

iv. ALGORITHM BASIC CONTROL STRUCTURES

Looping (repetition) is used to repeat statements while certain conditions are met.

Page 15: CC112 Structured Programming Lecture 1 1 Arab Academy for Science and Technology and Maritime Transport College of Engineering and Technology Computer

15

PROGRAM1 . . .

SUBPROGRAM1 a meaningful collection of SEQUENCE, SELECTION, LOOP, SUBPROGRAM

a subprogram is used to break the program into smaller units

iv. ALGORITHM BASIC CONTROL STRUCTURES

Page 16: CC112 Structured Programming Lecture 1 1 Arab Academy for Science and Technology and Maritime Transport College of Engineering and Technology Computer

Finding the area and circumference of a circle.

1. Analyze the problem. The problem input is the radius of the circle.

There are two outputs requested: the area and the circumference.

From our knowledge of geometry, we know the relationship between the radius of the circle and it area and circumference.

16

v. Sample Problem

Page 17: CC112 Structured Programming Lecture 1 1 Arab Academy for Science and Technology and Maritime Transport College of Engineering and Technology Computer

2. DESIGN THE ALGORITHM TO SOLVE THE PROBLEM.

1) Get circle radius

2) Calculate area using the following equation:area= π r2

3) Calculate area using the following equation:circumference=2πr

4) Display area and circumference values.

17

v. Sample Problem

Page 18: CC112 Structured Programming Lecture 1 1 Arab Academy for Science and Technology and Maritime Transport College of Engineering and Technology Computer

3. IMPLEMENT THE ALGORITHM .

1) Convert this algorithm into program instructions using a programming language.

2) Our desired progamming language is C.

18

v. Sample Problem

Page 19: CC112 Structured Programming Lecture 1 1 Arab Academy for Science and Technology and Maritime Transport College of Engineering and Technology Computer

19

THANK YOU