Lecture 1_introduction to Programming
Lecture 1_introduction to Programming
PROGRAMMING
Msangi, R.I
OUTLINE
● Overview
● Computer program
● Computer programming language
● Program syntax
● Statements
● Expressions
● Blocks
OVERVIEW
● Computer programming is The process of designing and writing
instructions (codes) that a computer can execute to perform specific
tasks or solve problems. It involves creating algorithms and translating
them into a programming language..
● Coding: This refers to the process of writing code in a specific
programming language. It involves translating algorithms and logic into
a syntax that a computer can understand. Coding is typically seen as
a more technical and focused activity.
● Computer programs are written using a computer programming
language
COMPUTER PROGRAM
A computer program is a sequence of instructions written using a
computer programming language to perform a specified task by the
computer
The two important terms that we have used in the above definition
are:-
● Sequence of instructions
● Computer Programming language
COMPUTER PROGRAM
● Declaration statements
○ Defines variables, functions/methods and objects
○ With declaration statements, variables, functions and
objects are created into being
○ E.g.
■ int age;
○ The above statement has created a variable called age
which will hold integer values
PROGRAM STATEMENTS
● Assignment statements
○ Assigns a value to a to a program variable
○ E.g.
■ age = 17;
● The above statement assigns the value 17 to a
variable age.
■ float height = 1.65;
● The above statement creates a variable height of
type float and assigns a value 1.65 to it.
PROGRAM STATEMENTS
● Expression statements
○ A statement that evaluates into a value
○ E.g.
■ z=x+y;
○ The above statement returns the sum of x and y and
assigns it to the variable z.
PROGRAM STATEMENTS
● Iteration statements
○ Iteration statements instruct the program to repeat a series of statements
a specified number of times depending on some set conditions
○ E.g.
while(stop==true){
/* code to be executed */
}
● The above statement executes the block of code within {...} as long as the
value of stop is true
PROGRAM STATEMENTS
● Decision statements
○ Decision statements decides the order of execution of statements
○ Statements are executed depending on some set conditions.
○ E.g.
if(age>=18){
print(“Adult”);
}else{
print(“Still a boy”);
○ The above flow control statement Displays ‘Adult’ if age is greater or equal to 18, otherwise
it displays ‘Still a boy’.
PROGRAM STATEMENTS