Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Class notes

Class notes, computer science

Rating
-
Sold
-
Pages
5
Uploaded on
23-12-2024
Written in
2024/2025

Complete, well written description on computer Algorithm as well as Logic and gates.

Institution
Freshman / 9th Grade
Course
Chemistry, computer science, economics

Content preview

THE THREE BASIC CONSTRUCTS Paper: 2


The Three Basic Constructs:
The three basic programming constructs: sequence, selection and iteration, allows us to control
how the program will execute the statements in it
1. Sequence: A sequence is a control structure in which a set of instructions is each executed
once, in the order in which they are written.

Example: The following program is an example of sequence that calculates the average of two numbers.
declare total as integer
declare average as real
declare a, b as integer
input a
input b
total = a + b
average = total/2
output total, average


2. Selection: Selection is a control structure in which an option of statements is provided and a
condition is used to decide which (if any) statements should be executed. The selection includes:
a) IF statements
b) CASE statements

a) IF statements: The common format/Syntax of IF statements are given below

i) IF <condition> THEN
<Statement>
END IF

ii) IF <condition> THEN
< Statement1>
ELSE
< Statement2 >
END IF

Example 1: (a/i)

IF amount >= 10 Then
Print “You can have Tea”
End If

IF amount >= 20 Then
Print “You can have Coffee”
End If

IF amount >= 50 Then
Print “You can have Ice-cream”
End If

Teacher: Md Nazrul Islam Email: | School: BAF SEMS 1

, THE THREE BASIC CONSTRUCTS Paper: 2

Example 2: (a/ii)

IF mark >= 50 Then
Print “Student Passed”
Else
Print “Student Failed”
End If


Example 3: (a/ii) [Do the dry run of it]

total = 15
k=5

input k

IF k >= 3 THEN
k=k*k
total = total + k
ELSE
total = total + k
END IF

print total

b) Syntax of CASE statements: The common format of CASE statement is given below:

SELECT CASE <expression>
CASE <value1>
<One or more statements>
CASE <value2>
< One or more statements >
CASE <value3>
< One or more statements >




CASE Else
< One or more statements >
END SELECT




Teacher: Md Nazrul Islam Email: | School: BAF SEMS 2

Written for

Institution
Freshman / 9th grade
Course
Chemistry, computer science, economics
School year
4

Document information

Uploaded on
December 23, 2024
Number of pages
5
Written in
2024/2025
Type
Class notes
Professor(s)
Idk
Contains
All classes

Subjects

$10.89
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
rafiqicbd

Get to know the seller

Seller avatar
rafiqicbd
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
1 year
Number of followers
0
Documents
1
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions