0% found this document useful (0 votes)
13 views21 pages

Lecture 1- 21-Jan-2025

Chapter 1 introduces the fundamentals of computer programming, covering the components of a computer, their interactions, and how information is stored and manipulated. It distinguishes between hardware and software, outlines the role of the CPU, and explains how digital information is represented using binary numbers. The chapter also discusses problem-solving in programming, emphasizing the importance of understanding problems and developing algorithms to create effective solutions.

Uploaded by

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

Lecture 1- 21-Jan-2025

Chapter 1 introduces the fundamentals of computer programming, covering the components of a computer, their interactions, and how information is stored and manipulated. It distinguishes between hardware and software, outlines the role of the CPU, and explains how digital information is represented using binary numbers. The chapter also discusses problem-solving in programming, emphasizing the importance of understanding problems and developing algorithms to create effective solutions.

Uploaded by

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

Chapter 1

Introduction to Computer Programming


Outline
• We first need to explore the fundamentals of computer processing

• Chapter 1 focuses on:


• components of a computer
• how those components interact
• how computers store and manipulate information
• programming and programming languages

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

• A computer requires both hardware and software


• Each is essentially useless without the other

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:

The CPU retrieves an instruction from main memory

fetch

execute decode

Carry out the Determine what the


instruction instruction is

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

• In some way, all information is digitized

7
Representing Text Digitally
• For example, every character is stored as a number, including spaces,
digits, and punctuation

• Corresponding upper and lower case letters are separate characters


Hi, Heather.

72 105 44 32 72 101 97 116 104 101 114 46

8
Binary Numbers
• Once information is digitized, it is represented and stored in memory
using the binary number system

• A single binary digit (0 or 1) is called a bit

• A single bit can represent two possible states, like a light bulb that is
either on (1) or off (0)

• Combinations of bits are used to store values

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

Each additional bit doubles the number of possible combinations

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

9278 Each memory cell stores a


9279 10011010 set number of bits (usually 8
9280 bits, or one byte)
9281
9282
9283 Large values are
9284 stored in consecutive
9285 memory locations:
9286 For example, a 32-bit integer requires
4 bytes (or 4 memory cells),
and a 64-bit floating-point number requires
8 bytes (or 8 memory cells).
Main memory is divided
into many memory
locations (or cells)
12
Storage Capacity
• Every memory device has a storage capacity, indicating the number of
bytes it can hold
• Capacities are expressed in various units:
Unit Symbol Number of Bytes
10
kilobyte KB 2 = 1024
megabyte 20
MB 2 (over 1 million)
gigabyte
30
terabyte GB 2 (over 1 billion)
40
TB 2 (over 1 trillion)

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

• Most operating systems and application programs have a graphical


user interface (GUI)
The Command Prompt is a program that comes pre-installed
with operating systems like Windows, Unix, or Linux. It allows
users to interact with the computer system by typing text-
based commands, making it software.
14
What is programming?
Computers perform tasks
• more efficiently, quickly, and accurately than we could by
hand
• However, to be useful it must be programmed

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

Think first and code later


Ada code
What is an Algorithm?

• 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.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy