COMPUTATIONAL THINKING
INTRODUCTION TO PROGRAMMING, B7
PROGRAMMING TERMINOLOGIES
What is Programming ?
Is the 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.
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.
Pseudocode : it is used to plan out the logic of a computer program, using English words or phrases.
Algorithm : is a step by step problem-solving process in which a solution is arrived at in a finite amount of
time.
Programming Languages: They are set of commands, govern by rules for creating a software.
Compilers : They translates computer code written in one programming language into another programming
PROGRAMMING DEVELOPMENT CYCLE
The following are the scientific method of
developing a program
Analyzing the problem
Design a program to solve the problem
Code the program
Test the program
Revise as necessary
DATA TYPES IN PROGRAMMING
Each piece of data ( a single character, a number or strings) is
stored in at least one memory location. The amount of space
allocated to the data actually depends on the data types.
In some programming languages, data must declared before use
and in other languages, they are not strict on declaring variables.
Some of the data types are as follows
Character Data types
string Data types
Integer Data types
Floating point Variables
Boolean Data type
Double etc
STRING DATA TYPES
A string is a sequence of characters.
• In most programming languages, strings are
enclosed in quotation marks (“ ”).
• Example: val = "Enter the first number:” ans =
“My name is Peter.”
• A single character is also considered to be a
string, so "B" and "g" are strings.
• A string may be void of any characters, it’s
called the null string
STRING DATA TYPE CONT’D
• In many programming languages,
concatenation, takes two strings and joins
them to produce a string result.
• The symbol that is often used to
concatenate two strings is the plus sign,
CHARACTER DATA TYPE EXAMPLES
•A character is any symbol that can be typed at
the keyboard. • This includes the letters of the
alphabet (uppercase and lowercase), numbers,
punctuation marks, spaces, and some of the
extra characters that a computer keyboard
contains, such as the pipe key ( | ), the various
types of brackets (curly brackets { } or square
brackets [ ]), and other special characters like $,
INTEGER DATA
Integers are all the positive, negative, or zero whole
numbers.
Examples are follows
20 is an integer,
344563 is an integer
- 17 is an integer
- 4536627 is an integer
0 is an integer
FLOATING POINT VARIABLES
Numbers are said to be floating when they have both the integer part and a
fractional part.
Such numbers takes more space in memory allocation and therefore cannot
be define as integers.
Examples of such numbers are
4.90
- 344.784
- 0.8888888
0.666666666
½
BOOLEAN DATA TYPES
A Boolean data variable can only have true or
false value.
In Boolean variable, 1 represents true and a 0
represent false.
HOW TO USE CONSTANTS AND VARIABLES
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.
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,
HOW TO USE CONSTANTS AND VARIABLES CONT’D
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