Lecture 1- 21-Jan-2025
Lecture 1- 21-Jan-2025
2
Hardware and Software
• Hardware
• the physical, tangible parts of a computer
• keyboard, monitor, wires
• Software
• programs and data
• a program is a series of instructions
3
Computer hardware
• Most computer have four major hardware parts
• Central Processing Unit (CPU)
• brain of the computer
• executes individual commands of a program and controls other components to perform
tasks
• Input/output devices
• allow human beings to interact with a computer: examples include keyboards, mice,
monitors, and printers
• Memory
• stores programs and data while the CPU processes them
The Central Processing Unit
• A CPU is also called a microprocessor
• It continuously follows the fetch-decode-execute cycle:
fetch
execute decode
5
Computer hardware
Chip that executes program commands
Monitor
Central
I/O devices allow user Processing
interaction Keyboard Unit
Monitor screen
Keyboard
Mouse
Bar code scanner Hard Disk Information is moved
Light pen Main between main memory
Touch screen Memory and secondary memory
as needed
Primary storage area for Floppy Disk
programs and data that Secondary memory
are in active use devices provide
Synonymous with RAM long-term storage 6
Digital Information
• Computers store all information digitally:
• numbers
• text
• graphics and images
• audio
• video
• program instructions
7
Representing Text Digitally
• For example, every character is stored as a number, including spaces,
digits, and punctuation
8
Binary Numbers
• Once information is digitized, it is represented and stored in memory
using the binary number system
• A single bit can represent two possible states, like a light bulb that is
either on (1) or off (0)
9
Bit Combinations
1 bit 2 bits 3 bits 4 bits
0 00 000 0000 1000
1 01 001 0001 1001
10 010 0010 1010
11 011 0011 1011
100 0100 1100
101 0101 1101
110 0110 1110
111 0111 1111
10
Bit Combinations
• Each combination can represent a particular item
• There are 2N combinations of N bits
• Therefore, N bits are needed to represent 2N unique items
1 bit ? 1
2 = 2 items
2 bits ? 2
How many 2 = 4 items
items can be 3 bits ? 3
2 = 8 items
represented by
4
4 bits ? 2 = 16 items
5
5 bits ? 2 = 32 items
11
Storing Information Each memory cell has a numeric address, which uniquely
identifies it
13
Software Categories
• Operating System
• controls all machine activities
• provides the user interface to the computer
• manages resources such as the CPU and memory
• Windows, Unix, Linux, Mac OS
• Application program
• generic term for any other kind of software
• word processors, games
Computer programming:
• set of instructions : to be executed by a computer
• In order to solve a given real world problem
Problem Solving
• The purpose of writing a program is to solve a problem
• The general steps in problem solving are:
• Understand the problem
• Dissect the problem into manageable pieces
• Design a solution
• Consider alternatives to the solution and refine it
• Implement the solution
• Test the solution and fix any problems that exist
16
Problem Solving
• Many software projects fail because the developer didn't really
understand the problem to be solved
• We must avoid assumptions and clarify ambiguities
• As problems and their solutions become larger, we must organize our
development into manageable pieces
• This technique is fundamental to software development
• We will dissect our solutions into pieces called classes and objects,
taking an object-oriented approach
17
How do we write a program?
Problem-Solving Implementation
Phase Phase
Analysis and
What exactly needs to be specification Concrete
done? What inputs will solution
the program have? What General (Program)
outputs are expected? solution
What are the constraints (Algorithm)
or limitations? Test
Verify
Maintenance
Phase
Programming shortcut
Problem Solving
Phase
Problem (Algorithm)
Shortcut?
Implementation
Phase JAVA code
(code)
Algorithm C++ code
• An algorithm is a sequence of instructions that a computer must perform to solve a well-defined problem.
• Algorithms use a set of initial data or input, process it through a series of logical steps or rules, and produce
the output (i.e., the outcome, decision, or result).
Example of an Algorithm
• Let’s consider for example an algorithm that calculates the square of a
given number.