CC112 Structured Programming
Lecture 1
1
Arab Academy for Science and Technology and Maritime Transport
College of Engineering and Technology
Computer Engineering Department
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
2
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)
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
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
LECTURE 1
Overview of Computer, Programming and
Problem Solving
6
LECTURE OUTLINE
i. What is a Program?
ii. What is Programming?
i. Programming Life-Cycle Phases
ii. Algorithm Basic Control Structures
iii. Sample problem
7
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
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:
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
Test and
verify
• 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.
Maintain
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
iv. ALGORITHM BASIC CONTROL
STRUCTURES
12
 a sequence is a series of statements that
execute one after another.
Statement Statement Statement . . .
13
IF Condition THEN Statement1 ELSE Statement2
Statement1
Statement
Statement2
Condition . . .
iv. ALGORITHM BASIC CONTROL
STRUCTURES
 selection (branch) is used to execute
different statements depending on
certain conditions.
14
Statement
Condition
. . .
False
WHILE Condition Statement1
iv. ALGORITHM BASIC CONTROL
STRUCTURES
 Looping (repetition) is used to repeat
statements while certain conditions are
met.
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
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
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
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
19

65_96195_CC112_2014_1__1_1_week1.pdf

  • 1.
    CC112 Structured Programming Lecture1 1 Arab Academy for Science and Technology and Maritime Transport College of Engineering and Technology Computer Engineering Department
  • 2.
    COURSE GOALS  IntroduceGeneral concepts of Programming  Begin to Think Like a Programmer  Start Programming With C (a powerful, widely-used programming language)  Become Junior C Programmer 2
  • 3.
    COURSE OUTLINE: 3  Introductionto 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)
  • 4.
    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
  • 5.
    COURSE TEXTBOOK  CHow 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
  • 6.
    LECTURE 1 Overview ofComputer, Programming and Problem Solving 6
  • 7.
    LECTURE OUTLINE i. Whatis a Program? ii. What is Programming? i. Programming Life-Cycle Phases ii. Algorithm Basic Control Structures iii. Sample problem 7
  • 8.
    i. WHAT ISPROGRAM?  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
  • 9.
    ii. WHAT ISPROGRAMMING?  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:
  • 10.
    Analyze • This involvesidentifying 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
  • 11.
    Test and verify • Runthe 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. Maintain 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
  • 12.
    iv. ALGORITHM BASICCONTROL STRUCTURES 12  a sequence is a series of statements that execute one after another. Statement Statement Statement . . .
  • 13.
    13 IF Condition THENStatement1 ELSE Statement2 Statement1 Statement Statement2 Condition . . . iv. ALGORITHM BASIC CONTROL STRUCTURES  selection (branch) is used to execute different statements depending on certain conditions.
  • 14.
    14 Statement Condition . . . False WHILECondition Statement1 iv. ALGORITHM BASIC CONTROL STRUCTURES  Looping (repetition) is used to repeat statements while certain conditions are met.
  • 15.
    15 PROGRAM1 . . . SUBPROGRAM1 ameaningful collection of SEQUENCE, SELECTION, LOOP, SUBPROGRAM  a subprogram is used to break the program into smaller units iv. ALGORITHM BASIC CONTROL STRUCTURES
  • 16.
    Finding the areaand 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
  • 17.
    2. DESIGN THEALGORITHM 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
  • 18.
    3. IMPLEMENT THEALGORITHM . 1) Convert this algorithm into program instructions using a programming language. 2) Our desired progamming language is C. 18 v. Sample Problem
  • 19.