Programming Fundamentals Cyber Security Muhammad Jalal Shah
Name of Student: _ Section: _
Student’s Signature: Date: _
Name of Instructor: Instructor’s Signature: _
Introductory Lab
Lab Objective:
In this lab, you will learn:
● What is System Software & Application Software, Number
Systems, Memory Hierarchy, Memory Units, Algorithms vs.
pseudocode, Flow Chart, Type of Languages (High level/ Low
level).
Lab Description:
Computer: A computer is a device that takes input from the user, processes the
data, and generates the output by following sets of instructions.
Operations performed by computers:
1. Data Processing: Computers can manipulate data in various ways, such as
performing calculations, sorting, searching, and transforming information.
2. Storage: They can store large amounts of data in different forms, from text
documents and images to videos and databases.
3. Communication: Computers can send and receive data over networks,
enabling them to connect with other computers, devices, and the internet.
4. Automation: They are used for automating repetitive tasks and processes,
increasing efficiency in various industries and applications.
5. Multitasking: Modern computers can handle multiple tasks simultaneously,
thanks to their multitasking capabilities.
6. User Interaction: Computers have input and output devices, such as
keyboards, mice, displays, and speakers, that allow users to interact with
them.
7. Entertainment: They are used for gaming, multimedia playback, and
other forms of entertainment.
8. Problem Solving: Computers are used to solve complex problems through
algorithms and simulations.
Programming Fundamentals Cyber Security Muhammad Jalal Shah
Computer Systems: Hardware and Software
Hardware: refers to the physical components that a computer has. A computer
system consists of the following major components:
1. The central processing unit (CPU)
2. Main memory (random-access memory, or RAM)
3. Secondary storage devices
4. Input devices (keyboard, joystick, touchscreen, webcam, microphone)
5. Output devices (monitor, printer, speaker, headphone, projector)
Software: is a set of instructions, data or programs used to operate computers and
execute specific tasks. It is the opposite of hardware, which describes the physical
aspects of a computer.
System Software vs Application Software
System Software Application Software
System Software maintains the system Application software is built for
resources and gives the path for application software specific tasks.
to run.
Low-level languages are used to write the system While high-level languages are used
software. to write the application software.
It is general-purpose software. While it’s a specific purpose
software.
Without system software, the system stops and can’t While Without application software
run. system always runs.
System software runs when the system is turned on While application software runs as
and stops when the system is turned off. per the user’s request.
Programming Fundamentals Cyber Security Muhammad Jalal Shah
Example: System software is an Example: Application software is
operating system, etc. Photoshop, VLC player, etc.
System Software programming is more complex Application software programming is
than application software. simpler in comparison to system
software.
NUMBER SYSTEM
Number systems are the technique to represent numbers in the computer system
architecture, every value that you are saving or getting into/from computer memory
has a defined number system.
Computer architecture supports the following number systems.
Binary number system
Octal number system
Decimal number system
Hexadecimal (hex) number system
BINARY NUMBER SYSTEM
A Binary number system has only two digits that are 0 and 1. Every number
(value) represents 0 and 1 in this number system. The base of binary number
system is 2, because it has only two digits.
OCTAL NUMBER SYSTEM
Octal number system has only eight (8) digits from 0 to 7. Every number (value)
represents with 0,1,2,3,4,5,6 and 7 in this number system. The base of octal number
system is 8, because it has only 8 digits.
DECIMAL NUMBER SYSTEM
Decimal number system has only ten (10) digits from 0 to 9. Every number (value)
represents with 0,1,2,3,4,5,6, 7,8 and 9 in this number system. The base of decimal
number system is 10, because it has only 10 digits.
HEXADECIMAL NUMBER SYSTEM
A Hexadecimal number system has sixteen (16) alphanumeric values from 0 to 9
and A to F. Every number (value) represents with 0,1,2,3,4,5,6, 7, 8, 9, A, B, C, D, E
and F in this number system. The base of hexadecimal number system is 16,
because it has 16 alphanumeric values. Here A is 10, B is 11, C is 12, D is 14, E is 15
and F is 16
Programming Fundamentals Cyber Security Muhammad Jalal Shah
1. BINARY TO DECIMAL Conversion
2. BINARY TO OCTAL
An easy way to convert from binary to octal is to group binary digits into sets of
three, starting with the least significant (rightmost) digits.
Binary: 11100101 = 11 100 101
011 100 101 Pad the most significant digits with zeros if
necessary to complete a group of three.
Then, look up each group in a table:
Binary: 000 001 010 011 100 101 110 111
Octal: 0 1 2 3 4 5 6 7
Binary = 011 100 101
Octal = 3 4 5 = 345 oct
3. BINARY TO HEXADECIMAL
An equally easy way to convert from binary to hexadecimal is to group binary digits
into sets of four, starting with the least significant (rightmost) digits.
Binary: 11100101 = 1110 0101
Then, look up each group in a
table:
Binary: 0000 0001 0010 0011 0100 0101 0110 0111
Hexadecimal: 0 1 2 3 4 5 6 7
Binary: 1000 1001 1010 1011 1100 1101 1110 1111
Hexadecimal: 8 9 A B C D E F
Binary = 1110 0101
Hexadecimal = E 5 = E5 hex
OCTAL TO OTHER
1. OCTAL TO BINARY
Programming Fundamentals Cyber Security Muhammad Jalal Shah
Converting from octal to binary is as easy as converting from binary to octal.
Simply look up each octal digit to obtain the equivalent group of three binary
digits.
Octal: 0 1 2 3 4 5 6 7
Binary: 000 001 010 011 100 101 110 111
Octal = 3 4 5
Binary = 011 100 101 = 011100101 binary
2. OCTAL TO HEXADECIMAL
When converting from octal to hexadecimal, it is often easier to first convert the
octal number into binary and then from binary into hexadecimal. For example, to
convert 345 octal into hex: (from the previous example)
Octal = 3 4 5
Binary = 011 100 101 = 011100101 binary
Drop any leading zeros or pad with leading zeros to get groups of four binary
digits (bits): Binary 011100101 = 1110 0101
Then, look up the groups in a table to convert to hexadecimal
digits. Binary: 0000 0001 0010 0011 0100 0101 0110 0111
Hexadecimal: 0 1 2 3 4 5 6 7
Binary: 1000 1001 1010 1011 1100 1101
1110 1111 Hexadecimal: 8 9 A B C D E F
Binary = 1110 0101
Hexadecimal = E 5 = E5
hex
Memory Units
Programming Fundamentals Cyber Security Muhammad Jalal Shah
High- and Low-Level Languages
Both High level language and low-level language are the programming language’s
types. The main Difference between high level language and low-level language is
that, Programmers can easily understand or interpret or compile the high-level
language in comparison of machine. On the other hand, Machine can easily
understand the low-level language in comparison of human beings. Examples of
high-level languages are C, C++, Java, Python, etc. Let’s see the difference between
high level and low-level languages:
Programming Fundamentals Cyber Security Muhammad Jalal Shah
High level language low-level language
1. It is programmer friendly language. It is a machine friendly language.
High level language is less
2. Low level language is high memory
memory efficient.
efficient.
3. It is easy to understand. It is tough to understand.
4. Debugging is easy. Debugging is complex comparatively.
5. It is simple to maintain. It is complex to maintain comparatively.
7. It can run on any platform. It is machine dependent.
It needs compiler or interpreter for It needs assembler for translation.
8. translation.
It is used widely for programming. It is not commonly used now-a-days in
9. programming.
Memory Hierarchy Design
1. Registers
Programming Fundamentals Cyber Security Muhammad Jalal Shah
Registers are small, high-speed memory units located in the CPU. They are used to
store the most frequently used data and instructions. Registers have the fastest
access time and the smallest storage capacity, typically ranging from 16 to 64 bits.
2. Cache Memory
Cache memory is a small, fast memory unit located close to the CPU. It stores
frequently used data and instructions that have been recently accessed from the
main memory. Cache memory is designed to minimize the time it takes to access
data by providing the CPU with quick access to frequently used data.
3. Main Memory
Main memory, also known as RAM (Random Access Memory), is the primary memory
of a computer system. It has a larger storage capacity than cache memory, but it is
slower. Main memory is used to store data and instructions that are currently in use
by the CPU.
4. Secondary Storage
Secondary storage, such as hard disk drives (HDD) and solid-state drives (SSD), is a
non-volatile memory unit that has a larger storage capacity than main memory. It is
used to store data and instructions that are not currently in use by the CPU.
Secondary storage has the slowest access time and is typically the least expensive
type of memory in the memory hierarchy.
5. Magnetic Disk
Magnetic Disks are simply circular plates that are fabricated with either a metal or a
plastic or a magnetized material. The Magnetic disks work at a high speed inside the
computer and these are frequently used.
6. Magnetic Tape
Magnetic Tape is simply a magnetic recording device that is covered with a plastic
film. It is generally used for the backup of data. In the case of a magnetic tape, the
access time for a computer is a little slower and therefore, it requires some amount
of time for accessing the strip.
Algorithm, Pseudocode and Flowchart
Programming Fundamentals Cyber Security Muhammad Jalal Shah
Pseudocode
High level descriptions of a computer program or algorithm that uses simple English like
statements to outline the basic logic of the program.
It helps programmers to write the logic of the program by breaking down the
problem into smaller ones.
Easy to communicate with non-programmers.
Save time and prevent mistakes.
How to write a Pseudocode
Understand the problem.
Break down the problems into smaller steps.
Example
Question: Write a pseudocode to add two numbers?
Write a program to add two numbers .
(Problem) Take two numbers from users.
Add the two numbers together.
Display the sum of two numbers.
Flowchart
· Visual program design tool
· Semantic symbols describe operations to be performed.
Programming Fundamentals Cyber Security Muhammad Jalal Shah
Programming Fundamentals Cyber Security Muhammad Jalal Shah
Algorithm
· Set of step-by-step instructions that perform a specific task or operation.
Lab Tasks:
TASK1:
Give five examples of system and application software’s.
TASK2:
Convert (219)10 decimal numbers in binary, Octal, and Hexadecimal.
TASK3:
Write the Difference between Register, Ram, and Main Memory in
terms of storage and processing.
TASK4:
Write a pseudocode to print even numbers and draw its flowchart.
*****