1 Computer Programming Introduction
1 Computer Programming Introduction
1. INTRODUCTION
3
DEFINITIONS
4
USER, PROGRAM AND PROGRAMMER RELATIONSHIP
CODING
OUTPUT
5
PROGRAMMING LANGUAGE
6
PROGRAMMING LANGUAGE HISTORY
Programming languages are called "lower" or "higher," depending on how close they are to the language
the computer itself uses or to the language people use
7
PROGRAMMING LANGUAGE PARTS
Syntax: grammar rules for defining legal statements – what's grammatically legal?
Semantics: what things mean – what do they compute?
Statements: instructions that say what to do – compute values, make decisions, repeat sequences of
operations
Variables: places to hold data in memory while program is running – numbers, text
Most languages are higher-level and more expressive than the assembly language( Environment “editor,
compiler, debugger, builder… etc”)
8
WHY DO ENGINEERS NEED TO STUDY PROGRAMMING
9
PROGRAMMING STEPS
1 2 3 4 5
• Clarify the • Design a • Code the • Test the • Document
problem solution program program and
maintain
the
program
10
PROGRAMMING STEPS
11
PROGRAMMING STEPS
12
PROGRAMMING STEPS
13
PROGRAMMING STEPS
14
PROGRAMMING STEPS
15
ILLUSTRATED EXAMPLE
Example: Write a program that calculates the area of any circle given its
diameter.
16
ILLUSTRATED EXAMPLE
Diameter (D)
What are the inputs?
The diameter of the circle (D) in certain units.
A=Pi * D2/4 18
ILLUSTRATED EXAMPLE
19
ILLUSTRATED EXAMPLE
Diameter (D)
20
ALGORITHMS
In programming, algorithms are the set of well defined instructions in sequence to solve a program.
21
SOURCE: http://www.programiz.com/article/flowchart-programming
ALGORITHM EXAMPLE I
Step 1: Start
Step 4: Add num1 and num2 and assign the result to sum.
sum←num1+num2
Write an algorithm to find the largest among three different numbers entered by user.
Step 1:
Start
Step 2:
Declare variables a,b and c.
Step 3:
Read variables a,b and c.
Step 4:
If a>b
If a>c
Display a is the largest number.
Else
Display c is the largest number.
Else
If b>c
Display b is the largest number.
Else 23
Display c is the largest number.
Step 5: Stop SOURCE: http://www.programiz.com/article/flowchart-programming
ALGORITHM EXAMPLE III
Step 1: Start
Step 2: Declare variables a, b, c, D, x1, x2, rp and
ip;
Step 3: Calculate discriminant
D←b2-4ac
Step 4: If D≥0
r1←(-b+√D)/2a
r2←(-b-√D)/2a
Display r1 and r2 as roots.
Else
Calculate real part and imaginary part
rp←b/2a
ip←√(-D)/2a
24
Display rp+j(ip) and rp-j(ip) as roots
Step 5: Stop
SOURCE: http://www.programiz.com/article/flowchart-programming
FLOWCHARTS
25
SOURCE: http://www.programiz.com/article/flowchart-programming
FLOWCHART ELEMENTS
Symbol Purpose Description
28
FLOWCHART EXAMPLE II
29
FLOWCHART EXAMPLE III
30
COURSE INFORMATION
31
COURSE INFORMATION: -GOALS
32
COURSE INFORMATION:- GRADING MODEL
* This distribution is subject to change. The student will be notified if changes occurred.
33
COURSE INFORMATION: -RECOMMENDED REFERENCES
1. John Walkenbach, “Excel VBA Programming for Dummies”, 2nd Edition, 2010.
34
COURSE INFORMATION :-THE COURSEWORK
Quizzes are expected in every lecture/laboratory session and they will be graded.
Avoid plagiarism.
35
COURSE INFORMATION :-THE COURSE OUTLINES
Browse reference.
Submit assignments.
36
GENERAL NOTES
Always have a notepad and a pen ready during sessions.
37
38