0% found this document useful (0 votes)
109 views

FCP 1 - Programming Logic

This document provides an overview of the Fundamentals in Programming module. It includes: 1) Details of the module such as name, code, credits, learning outcomes which focus on explaining programming concepts, designing programs, developing modular programs, and software testing. 2) Information on module delivery and evaluation including 150 learning hours through lectures, practical sessions, and student centered learning. Assessment is 100% coursework. 3) An introduction to understanding computer components, operations, and the evolution of programming languages from machine language to high-level languages.

Uploaded by

IM 99
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
109 views

FCP 1 - Programming Logic

This document provides an overview of the Fundamentals in Programming module. It includes: 1) Details of the module such as name, code, credits, learning outcomes which focus on explaining programming concepts, designing programs, developing modular programs, and software testing. 2) Information on module delivery and evaluation including 150 learning hours through lectures, practical sessions, and student centered learning. Assessment is 100% coursework. 3) An introduction to understanding computer components, operations, and the evolution of programming languages from machine language to high-level languages.

Uploaded by

IM 99
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 41

HD in Computing and Software

Engineering
CSE4002 : Fundamentals in Programming
Level: 4
Credit Value: 15

Lesson 01 – Introduction to Programming

Lecturer: Mrs. Nisansala Athapaththu (MSc (Pera), BSc (RUSL))


1 1/13/2021
Module Details
Module Name : Fundamentals in Programming
Module Code : CSE4002
Credits : 15
Level :4

Module Learning outcomes


LO1: Explain structured programming concepts
LO2: Design a basic structured computer program
LO3: Develop a modularized computer programme for a prepared design
LO4: Compile software testing and documentation

2
Module Delivery and Evaluation
Learning Hours : 150
Lectures 30 hours
Practical 30 hours
Student Centered Learning 90 hours
Teaching : Lecture and practical session (20 Sessions)

Assignment : 100% coursework (3000 words equivalent) including


system designing, implementation and testing documentation.
- End semester

3
Understanding Computer Components and
Operations
 Hardware: equipment, or devices, associated with a
computer
 For a computer to be useful, it needs more than
equipment; a computer needs to be given
instructions
 The instructions that tell the computer what to do
are called software, or programs, and are written by
programmers
4
Understanding Computer Components and
Operations (continued)
 Hardware devices that perform input include keyboards
and mice
 Through input devices,
 data, or facts, enter the computer system
 Processing data items may involve
 organizing them,
 checking them for accuracy, or
 performing mathematical operations on them

5
Understanding Computer Components and
Operations (continued)
 The hardware that performs these sorts of tasks is the
central processing unit, or CPU
 After data items have been processed, the resulting
information is sent to a printer, monitor, or some other
output device so people can view, interpret, and use the
results

6
The Language of a Computer
 Digital signals are sequences of 0s and 1s
 Machine language: language of a computer
 Binary digit (bit):
 The digit 0 or 1
 Binary code:
 A sequence of 0s and 1s
 Byte:
 A sequence of eight bits
7
Programming Language Evolution
 Early computers were programmed in machine language

 To calculate wages = rates * hours in machine language:

100100 010001 // Load


100110 010010 // Multiply
100010 010011 // Store

8
Assembly Language
 Assembly language instruction are mnemonic
 Assembler: translates a program written in assembly
language into machine language

9
Program Example
 Using the assembly language instructions, the equation
wages = rates * hours can be written as follows:

LOAD rate
MULT hour
STOR wages

10
High-Level Languages
 High-level languages include Basic, FORTRAN, COBOL,
Pascal, C++, C, and Java

 Compiler: translates a program written in a high-level


language machine language

 The equation wages = rate * hours can be written in C++


as: wages = rate * hours;

11
Language Style
 Every language has rules governing its word usage and
punctuation
 Programming rules are called the language’s syntax
 Each programming language uses a piece of software
to translate the specific programming language into
the computer’s on-off circuitry, or machine language

12
Language Style (continued)
 The language translation software, known as a compiler
or interpreter, tells you if you have used a programming
language incorrectly
 For a program to work properly, you must give the
computer exact instructions in a specific sequence
 By doing this, you are developing the logic of the
computer program
 Once instructions have been inputted to the computer
and translated into machine language, a program can be
run, or executed
13
Understanding the Programming Process
 The programmer’s job can be broken down into six
programming steps:

1. Understand the problem

2. Plan the logic

3. Code the program

4. Translate the program into machine language

5. Test the program

14 6. Put the program into production


1. Understand The Problem
 Really understanding the problem may be one of the
most difficult aspects of programming
 The description of what the user needs may be vague
 The user may not even really know what he or she wants
 Users who think they know what they want frequently change
their minds after seeing sample output
 A good programmer is often part counselor, part
detective

15
2. Plan the Logic
 Programmer plans the steps to the program, deciding
what steps to include and how to order them
 The two most common tools are flowcharts and
pseudocode
 Both tools involve writing the steps of the program in
English

16
3. Code the Problem
 Some very experienced programmers can successfully
combine the logic planning and the actual instruction
writing, or coding of the program, in one step

 A good term paper needs planning before writing, and so


do most programs

17
4. Translate the Program into Machine Language
 Languages such as Java or Visual Basic translate the
programmer’s English-like high-level programming language into
the low-level machine language that the computer understands

 If you write a programming language statement incorrectly (for


example, by misspelling a word, using a word that doesn’t exist
in the language, or using “illegal” grammar), the translator
program doesn’t know what to do and issues an error message
identifying a syntax error

18
4. Translate the Program into Machine Language
(continued)
 All syntax errors are caught by the compiler or interpreter

 When writing a program, a programmer might need to recompile


the code several times

 An executable program is created only when the code is free of


syntax errors

 When you run an executable program, it might also typically


require input data

19
Creating an Executable Program

20
5. Test the Program
 A program that is free of syntax errors is not
necessarily free of logical errors

 Once a program is free from syntax errors, the


programmer can test it—that is, execute it with some
sample data to see whether the results are logically
correct

21
6. Put the Program into Production
 Putting a program into production might mean simply
running the program once, if it was written to satisfy a
user’s request for a special list
 The process might take months if the program will be
run on a regular basis, or it is one of a large system of
programs being developed
 Conversion, the entire set of actions an organization
must take to switch over to using a new program or set
of programs, can sometimes take months or years to
22
accomplish
Let’s start with Logical Planning
With FLOW CHARTS and PSEUDO CODES

23 1/13/2021
Using Flowchart Symbols and Pseudocode
Statements
 Flowcharts (pictorial representations) and pseudocode
(English-like representations) are used by programmers to
plan the logical steps for solving a programming problem
 Some professional programmers prefer writing pseudocode
to drawing flowcharts, because using pseudocode is more
similar to writing final statements in programming language
 Almost every program involves the steps of input,
processing, and output, necessitating some graphical way to
separate them

24
Flow Chart symbols

 There are 6 basic symbols commonly used in flowcharting of


assembly language
 Terminal
 Process
 Input or Output
 Decision
 Connector
 Predefined Process
 Flow Lines

25 1/13/2021
Flow Chart symbols - Terminal

 Indicates the starting or ending of the program, process, or


interrupt program.

START
STOP
BEGIN

26 1/13/2021
Flow Chart symbols - Terminal
 In flowcharts:
 A terminal symbol, or start/stop symbol, should be included at
each end
 Often, “start” or “begin” is used as the first terminal symbol and
“end” or “stop” is used in the other
 The standard terminal symbol is shaped like a racetrack; often
called a lozenge, because it resembles the shape of a medicated
candy lozenge you might use to soothe a sore throat

27
Flow Chart symbols - process
 Indicates any internal operation inside the process/memory

Rate = 10.2
Amount = Price x Quantity
Sum = Mark1 + Mark2

28 1/13/2021
Using Flowchart Symbols
 Arithmetic operation statements are examples of
processing in a flowchart, where you use a rectangle as
the processing symbol containing a processing
statement

29
Flow Chart symbols - Input or Output
 Used for any input or output (I/O) operation. Indicates that the
computer is to obtain data or output result.

Input Output

Name, Age “Welcome to


ICBT…”

30 1/13/2021
Using Flowchart Symbols
 To represent an output statement, you use the
parallelogram, which is also the same symbol used for
input statements

31
Flow Chart symbols - Decision
 Used to ask a question that can be answered in a binary format.
 Example : (Yes or No), (True or False)

No / False IS Yes / True


?
Mark > 50

32 1/13/2021
Flow Chart symbols - Decision
 Example:

False if True
Score > 50

Grade = ‘F’ Grade = ‘P’

33 1/13/2021
Flow Chart symbols - Flow Lines
 Arrows, or flowlines, connect and show the appropriate sequence
of steps
 Important to Show the direction of flow

34 1/13/2021
Flow Chart symbols – Module / Predefined Process
 Used to invoke a Module / subroutine / unit / function or an interrupt
program.
 Modularization helps you to simplify logical diagrams

ModuleName()
• or ModuleName()

35 1/13/2021
Flow Chart symbols – Module /Predefined Process
 Modularized example:

36 1/13/2021
Flow Chart symbols - Connector

 Allow the flowchart to be drawn without intersecting lines or


without a reverse flow.

37 1/13/2021
Using the Connector
 You can use a connector when limited page size forces
you to continue a flowchart in an unconnected location
or on another page
 By convention, programmers use a circle as an on-page
connector symbol, and a symbol that looks like a square
with a pointed bottom as an off-page connector symbol

38
Using a Connector (continued)
 If a flowchart has six processing steps and a page provides room
for only three, you might represent the logic as shown below:

39
Using Flowchart Symbols and Pseudocode
Statements
 Figure shows a complete flowchart for the program that doubles a
number, and the pseudocode for the same problem

calculatedAnswer
= inputNumber x 2

40
Activity time
Designing Sequential Flow charts

Q1). Draw a flow chart and write the pseudocode for a program,
To input length and width of a rectangle and output area and perimeter of the
rectangle.
 Area = length * width
 Perimeter = 2 * (length + width)

Q2). Draw a flow chart and write the pseudocode for a program,
which input marks of 3 modules, Calculate and output Total and average marks
of the student.

41 1/13/2021

You might also like