Muhamad Rizal Bin Mohamed Razali Programming Concept / ISD Introduction
Course Work Breakdown Quiz =5% Midterm =15%() Assignment=15%() Lab=15% Final =50%
Learning Goals At the end of this module student will be able: Read the C program Design pseudocode and flow chat Write C program using selection , looping pointer and function command.
Outcome 3   Introduction & Objective Before we start writing a programming  it is essential to have a thorough  understanding  of the  problem  and carefully  planned approach  to solve the problem. We can use  Pseudocode  Flow chart method how to solve the problem
Outcome 3 Algorithm  is a sequence of steps or procedure to solve the problem. Example:- Let say you have a friend to enroll as a student at your collage. Can u tell your friend how he/she can enroll as a student at your collouge.
Manual process for enrollment Go to the receptionists  counter  Ask registration form Fill all the particulars Submit the form
Online process for enrollment Login to the collage website Click at the registration form Fill up the form Click submit button
Cont… Can you give me example algorithm how to cook Nasi goreng ?
Cont.. You have several algorithm to achieve the same goal  Every algorithm has a different cost and time  to accomplish.
Pseudocode An outline of a program written in English or the user's natural language; it is used to plan the program, and also serves as a source for test engineers doing software maintenance, it cannot be compiled.  You can write pseudocode without even knowing what programming language you will use for final implementation
Why needs pseudocode? Designing algorithms Communicating algorithm to users Implementing algorithms as programs Debugging logic error in programs  Documenting programs for future maintenance and expansion purpose
How to write pseudocode Have a limited vocabulary Be easy to learn Produce simple instruction or simple English like narrative notation Be capable of describing all algorithm , regardless of their complexity
Pseudocode Meaning Read  name Read a value from input device and store it under the specified name Write  name Write the value stored under the name to the output device Write  string Write whatever appears in the string name = expression Evaluate the expression and store it under specified name IF  condition  THEN  statements In the condition is true then execute the statements otherwise ignore them FOR  counter = 1 TO n  DO  statements Execute the statements ‘n’ times REPEAT  Statements  UNTIL  condition Repeat the statements over and over until the condition is true
Case study Write a pseudcedo to show how to withdraw money at ATM machine
Insert ATM card Key in password Chose withdraw menu Chose type of account Enter amount Remove ATM card Keep the money
Flow Chart Flow chart is a schematic representation of a process Flow chart is a graph consisting of geometrical shapes that are connected by flow lines In order to use flowcharts to communicate algorithms we must develop some convention for its symbols
Cont.. The basic flow chart symbols are as below:-
Descriptions  Symbols Start / End  Input / output Processing / computational Decision making /selection Flow line
Cont… Draw a flow chart based on the pseudocode below. display “enter your  name” accept first _name display “Enter your I/C number” accept  ic_number display “enter your  how many days you works:” accept days _your _work compute salary= 5.5 X days_your_work display  first_name , days your work , “your salary this month”,salary
Cont Salary = 5.5 X how many days Display first name I/C numbers & salary Start Enter first name Read first name Enter I/C number Read how many days Enter how many days Read I/C number End
Control Structure A  control structure  is a  design  that  determines  the  logic order  of program instructions Have 3 types of control structures Sequence control structure Selection control structure Repetition control structure
The sequence Control Structure Is a series of steps or statements that are executed in order  they are written in an algorithm
Selection control structure The selection control structure defines two courses of action depending on the outcome of a condition The selection structure requires use of the keywords  if   and  else .
Example… If  password true  Chose withdraw menu Chose account type Remove ATM card Keep the money Else   Reenter the password
Nested selection structure Nested selection structure is a  basic selection structure  that  contains other  if/else  structure in it’s then part or else part Useful for multi way decision making
Cont.. If  password true  If  menu equal balance enquiry  Chose account type Else  If  menu equal withdraw Chose account type Else Please enter the correct menu End if Else   Reenter the password End if
Repetition Control structure The repetition structure permits a sequence of instruction be executed  repeatedly  until a certain  condition is reached
Cont.. enter the password While  enter password not equal actual password  begin Repeat ask user to enter the password if user enter 3 times wrong password block the user end
Summary You learn  concept of problem solving Algorithm is sequence of a finite numbers of step arrange in a specific logical order. Algorithm can described in term of three basic control structure  Sequence Selection repetition
Questions Get two numbers as input from the user and display the sum of the two numbers to the screen. Get a series of 5 integers and display the total Read two numbers and compare which number is smaller and display the result Read 3 numbers and print the largest number

Chap3

  • 1.
    Muhamad Rizal BinMohamed Razali Programming Concept / ISD Introduction
  • 2.
    Course Work BreakdownQuiz =5% Midterm =15%() Assignment=15%() Lab=15% Final =50%
  • 3.
    Learning Goals Atthe end of this module student will be able: Read the C program Design pseudocode and flow chat Write C program using selection , looping pointer and function command.
  • 4.
    Outcome 3 Introduction & Objective Before we start writing a programming it is essential to have a thorough understanding of the problem and carefully planned approach to solve the problem. We can use Pseudocode Flow chart method how to solve the problem
  • 5.
    Outcome 3 Algorithm is a sequence of steps or procedure to solve the problem. Example:- Let say you have a friend to enroll as a student at your collage. Can u tell your friend how he/she can enroll as a student at your collouge.
  • 6.
    Manual process forenrollment Go to the receptionists counter Ask registration form Fill all the particulars Submit the form
  • 7.
    Online process forenrollment Login to the collage website Click at the registration form Fill up the form Click submit button
  • 8.
    Cont… Can yougive me example algorithm how to cook Nasi goreng ?
  • 9.
    Cont.. You haveseveral algorithm to achieve the same goal Every algorithm has a different cost and time to accomplish.
  • 10.
    Pseudocode An outlineof a program written in English or the user's natural language; it is used to plan the program, and also serves as a source for test engineers doing software maintenance, it cannot be compiled. You can write pseudocode without even knowing what programming language you will use for final implementation
  • 11.
    Why needs pseudocode?Designing algorithms Communicating algorithm to users Implementing algorithms as programs Debugging logic error in programs Documenting programs for future maintenance and expansion purpose
  • 12.
    How to writepseudocode Have a limited vocabulary Be easy to learn Produce simple instruction or simple English like narrative notation Be capable of describing all algorithm , regardless of their complexity
  • 13.
    Pseudocode Meaning Read name Read a value from input device and store it under the specified name Write name Write the value stored under the name to the output device Write string Write whatever appears in the string name = expression Evaluate the expression and store it under specified name IF condition THEN statements In the condition is true then execute the statements otherwise ignore them FOR counter = 1 TO n DO statements Execute the statements ‘n’ times REPEAT Statements UNTIL condition Repeat the statements over and over until the condition is true
  • 14.
    Case study Writea pseudcedo to show how to withdraw money at ATM machine
  • 15.
    Insert ATM cardKey in password Chose withdraw menu Chose type of account Enter amount Remove ATM card Keep the money
  • 16.
    Flow Chart Flowchart is a schematic representation of a process Flow chart is a graph consisting of geometrical shapes that are connected by flow lines In order to use flowcharts to communicate algorithms we must develop some convention for its symbols
  • 17.
    Cont.. The basicflow chart symbols are as below:-
  • 18.
    Descriptions SymbolsStart / End Input / output Processing / computational Decision making /selection Flow line
  • 19.
    Cont… Draw aflow chart based on the pseudocode below. display “enter your name” accept first _name display “Enter your I/C number” accept ic_number display “enter your how many days you works:” accept days _your _work compute salary= 5.5 X days_your_work display first_name , days your work , “your salary this month”,salary
  • 20.
    Cont Salary =5.5 X how many days Display first name I/C numbers & salary Start Enter first name Read first name Enter I/C number Read how many days Enter how many days Read I/C number End
  • 21.
    Control Structure A control structure is a design that determines the logic order of program instructions Have 3 types of control structures Sequence control structure Selection control structure Repetition control structure
  • 22.
    The sequence ControlStructure Is a series of steps or statements that are executed in order they are written in an algorithm
  • 23.
    Selection control structureThe selection control structure defines two courses of action depending on the outcome of a condition The selection structure requires use of the keywords if and else .
  • 24.
    Example… If password true Chose withdraw menu Chose account type Remove ATM card Keep the money Else Reenter the password
  • 25.
    Nested selection structureNested selection structure is a basic selection structure that contains other if/else structure in it’s then part or else part Useful for multi way decision making
  • 26.
    Cont.. If password true If menu equal balance enquiry Chose account type Else If menu equal withdraw Chose account type Else Please enter the correct menu End if Else Reenter the password End if
  • 27.
    Repetition Control structureThe repetition structure permits a sequence of instruction be executed repeatedly until a certain condition is reached
  • 28.
    Cont.. enter thepassword While enter password not equal actual password begin Repeat ask user to enter the password if user enter 3 times wrong password block the user end
  • 29.
    Summary You learn concept of problem solving Algorithm is sequence of a finite numbers of step arrange in a specific logical order. Algorithm can described in term of three basic control structure Sequence Selection repetition
  • 30.
    Questions Get twonumbers as input from the user and display the sum of the two numbers to the screen. Get a series of 5 integers and display the total Read two numbers and compare which number is smaller and display the result Read 3 numbers and print the largest number