0% found this document useful (0 votes)
18 views9 pages

Basic 8, Programming

The document provides an introduction to programming, defining it as a sequence of instructions executed by a computer to perform specific tasks. It covers basic programming concepts such as constants, variables, input, and naming identifiers, along with examples demonstrating their use. Additionally, it discusses arithmetic operations, operator precedence, and logical operators in programming.

Uploaded by

edemyaw15
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views9 pages

Basic 8, Programming

The document provides an introduction to programming, defining it as a sequence of instructions executed by a computer to perform specific tasks. It covers basic programming concepts such as constants, variables, input, and naming identifiers, along with examples demonstrating their use. Additionally, it discusses arithmetic operations, operator precedence, and logical operators in programming.

Uploaded by

edemyaw15
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 9

COMPUTATIONAL

THINKING
Introduction to Programming
WHAT IS PROGRAMMING?

Is a list of instructions that is executed by a computer to accomplished a particular task.


Or
Programming can also be said to be a sequence of instructions that specifies how to perform a
computation of a specific task.
BASIC CONCEPT IN PROGRAMMING.

Constants : Is define as values that are used within a program and do not change.
Variables : They are spaces that are reserved for data to be entered or can also be define as a
value within a program whose value can change during running of a program.
Input : it refers to information that is accepted from the user or other sources into a program.

NB: the input is not what the programmer enters but the user of the program. Example, if you
want to buy airtime from MTN, after dialing your mobile money short code, a menu then
displays and you are ask to enter an option, the option is the input your are doing.
VARIABLE AND
CONSTANTS
Data : data is input into a program variable.
A variable is a named of piece of memory whose value can change during the
running of the program.
Example 1: A program to calculate the average of three numbers.

Write “ Enter the first number”


Input : number
The variable here is number. Supposed the user enters 5 as the first number, then
that becomes a variable which could at any time change in the course of
programming.
CONSTANTS:
Example 2: a program to calculate the total cost of downloading a music online.
Input the number of songs to purchase, Songs
Input Songs
Compute the total cost:
Set TotalCost= 5.99 * Songs

Output the total cost:

Write TotalCost.
Can you identify the variable and constant in this program?
Variable used are Songs and TotalCost
The constant is : 5.99
NAMING OF IDENTIFIERS
Identifiers: They are name of things such as variable and constant that appears in a program.

 The following are basic rules for naming variables: NB: the rules are different for all
programming language, but these are generally accepted:
1. Identify name consist of letters, digits, the underscore character ( _ ), and the Dollar
sign( $ ) and MUST begin with a letter, underscore or the dollar sign.
2. Identifiers can be made of only letters, digits , the underscore and the dollar sign. No
other symbol is permitted as an identifier.
EXAMPLE:
1. first, NUMBER, Conversion, NaMe…………………..
2. payRate, ComputeAverage, Firstname, Lastname………..
3. Counter1, number1, num2, f2name.
4. $Amount, _amount, _Amount, _2place,
5. first_name,
OPERATIONS ON DATA
• Programming languages support some form of arithmetic operations
• Some arithmetic operations includes, addition, subtraction,
multiplication, division, exponentiation and modulus.
• Operator Computer symbol Example
Addition + 3 + 8 = 11
Subtraction - 9–4=5
Multiplication * 8 * 3 = 24
Division / 24 / 4 = 6
Exponentiation ^ 2^3 = 8
Modulus % 14 % 4 = 2
Hierarchy of Operations/ Operator
Precedence
• First: perform operations inside parenthesis ( from inside out if more
than one )
• Second: perform exponentiation
• Third: Do multiplications, divisions, and modulus from left to right. (if
there are more than one)
• Fourth: do additions and subtractions from left to right (if there are
more than one)
Example of hierarchy of Operations
3 * ( 6 + 2 )/ 12 + ( 7 – 5 )^ 2 * 3 = ?
( ) first : = 3* 8 / 12 + 2 ^ 2 * 3
^ next : = 3 * 8 / 12 + 4 * 3
Leftmost * next : = 24 /12 + 4 * 3
Division next: = 2 + 4 * 3
Multiply next: 2 + 12
Addition last = 14.

Can you try this 3 * 6 + 2/12 + (7- 5)^ (2 * 3) = ?


Is your answer 82.167 then you are correct.
LOGICAL OPERATORS

You might also like