Introduction To Programming
Introduction To Programming
EECP1290
Preliminary Concepts
What is a computer?
How does a computer work?
Numbers
Programming Languages
Machine Level
Assembly Level
High Level
ASSEMBLER
Machine Language
Program
COMPILER
Machine Language
Program
Levels of Languages
Fortran, C, Pascal
Machine Language
Hardware
Programming Steps
1. Write the algorithm
2. Draw the flowchart
3. Implement the program
Step 1. Algorithm
Steps that are written in English in order to
solve a problem
Cannot be understood by computers but
understood by programmers
Step 2. Flowchart
Pictorial data of a solution to a problem
Used to check flow of information from start
to end
Use standard symbols
Examples
Adding two numbers
Printing a name
Exercise
Write an algorithm to read the marks of a
student and then calculate the sum and
average
Convert the algorithm to flowchart
Step 3. Implementation
Convert the flowchart to code
Preprocessor Area
Program Execution
Compile the program
Run the program
The file must be named ICT exercise and must be put in a folder named Practice on the
Desktop
Solution
Review
What are the thee levels of
programming language?
Machine Level
Assembly Level
High Level
Review
It converts High Level Language to
Machine Language
Compiler
Review
It converts High Level Language to
Machine Language
Compiler
Review
Give another name for Machine
Language
Object Code, Binary Code
Review
It use mnemonic code or symbolic
code
Assembly Level Language
Review
What are the three programming
steps?
1. Algorithm
2. Flowchart
3. Code
Review
Steps written in English to solve a
programming problem
Algorithm
Review
Flowchart symbol used for input or
output
Review
What is the meaning of this
symbol?
Start / Stop
Review
Which line has the definition for
function getch()?
a.
b.
c.
#include stdafx.h
#include <iostream>
#include <conio.h>
Recall
Adding two numbers using algorithm and
flowchart
Declaration of Variables
Integer
Float
Character
Integer
Whole numbers including zero and negative
numbers
To declare an integer, use the keyword int
Example:
int A;
int A, B, C;
Float
Involves numbers with decimal parts
Use the keyword float for declaration
Example:
float X;
float Y, Z, W;
Character
Variables used to store alphabetical letters
To declare a character, use the keyword char
Example:
char M
char N, O, Y;
const
struct
else
void
register
do
while
double
unsigned
for
case
sizeof
extern
float
break
long
default
typedef
return
int
if
signed
enum
char
static
Initializing a Variable
Giving a variable an initial value
Example:
int A=5;
int D, E, F=7, G;
cin>>a;
Operators
Arithmetic
Relational
Logical
Arithmetic Operators
OPERATOR
ACTION
+
*
/
%
-++
Subtraction
Addition
Multiplication
Division
Modulus
Decrement
Increment
Relational Operators
OPERATOR
MEANING
>
>=
<
<=
==
!=
Greater than
Greater than or equal
Less than
Less than or equal
Equal
Not Equal
Logical Operators
OPERATOR
MEANING
&&
||
!
AND
OR
NOT
Review
Give three different types of
variables
integer
float
character
Review
Make a declaration for a variable with
name age that can accept an integer
value.
int age;
Review
What is the data type in the code
below?
char name, address, GSM;
character
Review
Declare a variable X and give it an
initial value of 3.28
float X=3.28
Review
Which is a valid variable name?
A.
B.
C.
D.
cout
first name
2ndname
_GSMNumber
Review
Give three different types of
operators
Arithmetic
Relational
Logical
Review
Give at least three arithmetic
operators
--
++
Review
Give the three logical operators
&&
||
Review
Find the answer for the following
1. X = 9*2+3-7%8
2. M = 4*4+4-4/4
3. S = (8+2*3) 23%4