IntroToComputer

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 40

Introduction to Programming

Introduction

• A computer is an electronic device that manipulates information, or data. It has


the ability to store, retrieve, and process data.

• Computer is an electronic device that takes raw data as an input from the user and
processes it under the control of a set of instructions (called program), produces a
result (output), and saves it for future use.

• A computer is a machine or device that performs processes, calculations and


operations based on instructions provided by a software or hardware program. It has
the ability to accept data (input), process it, and then produce outputs.
Conti…

3
Computer History
 1950's
◦ Large devices, accessible to few people
 1960's
◦ Commercial usage emerges
◦ Operated by experts
 1970's
◦ Computers cheaper, smaller
 1990's
◦ Computers fast, small, inexpensive
◦ Owned and used by many people

4
Basics of Computer

5
A Typical Computer System

Monitor Speaker
(output) (output)
System unit
(processor, memory…)
Printer
(output)

Storage devices
(CD-RW, Floppy,
Hard disk, zip,…)

Scanner
(input) Keyboard Mouse
(input) (input)

6
Elements of a Computer

Basic Elements of a Computer are:

• Hardware

• All physical components of a computer which can be touched like monitor,


keyboard, mouse etc.

• Software

• All components of a computer which can’t be touched which are designed to


perform a well-defined function like windows, media player etc.
Components of a Computer
Basically, All Computers have five basic
components

• Input unit

• Processing unit

• Control unit

• Memory unit

• Output unit
Input unit
• Responsible for taking data\information from user to perform operation.

• Devices through which a user can communicate with a computer

• These devices are

• Mouse

• Keyboard

• Touch screen

• Microphone

• Scanner
Processing unit

• Responsible for performing operations on the data/information provided by the user

• Also knows as Arithmetic & Logic unit

• Performs arithmetic operations like calculations on data in order to convert them into useful
information.

• Perform actions like a comparison of data and decision-making actions.


Control unit

• Responsible for smooth running of all components of a computer

• It is one of the most essential components of the computer system.

• The Control Unit collects the data entered using the input unit

• Provides data to processing unit.


Memory unit

• Responsible for storing data and results for future use

• These are of three types

• Cache Memory

• Fastest of all memory types.

• Primary Memory \ Main Memory

• Temporary memory

• Secondary Memory

• Slower of all memory types and Permanent memory


Primary memory
• Primary memory holds only those data and instructions on which the computer is
currently working.

• It has a limited capacity and data is lost when power is switched off. That is why it is
also called Temporary memory.

• The data and instruction required to be processed resides in the main memory.

• Two types

• RAM (Random Access Memory)

• ROM (Read Only Memory)


Secondary memory
• These are used for storing data/information permanently.

• This type of memory is also known as external memory or non-volatile.

• The contents of secondary memories are first transferred to the main memory, and then the
CPU can access it.

• Examples of Secondary memory are:

• Hard Disk

• Flash Disk \ USB

• CD\DVD
Output unit
• Responsible for providing the user with results produced by operations performed
on the provided data

• Devices used by a computer to communicate with a user

• These devices are:

• Monitor \ screen

• Printer

• Speaker

• Plotters
Primary Memory/ Primary Storage
• Primary Memory or Primary storage devices hold data temporarily

• These are internal to the Computer

• These are generally smaller in size

• These have faster access time

• Examples of Primary storage

• RAM (Random Access Memory)

• ROM (Read Only Memory)

• Cache
Random Access Memory (RAM)

• It is also called read-write memory or the main memory or the primary memory.

• The programs and data that the CPU requires during the execution of a program are stored in this
memory.

• Every time the computer needs to work on an application or program, the RAM is used to complete that
operation.
Read Only Memory (ROM)

• Stores crucial information essential to operate the system, like the program essential to boot the
computer.

• It is not volatile.

• Always retains its data.

• Used in embedded systems or where the programming needs no change.

• Used in calculators and peripheral devices.


Cache memory

• Cache Memory is a special very high-speed memory.

• Cache memory is an extremely fast memory type that acts as a buffer between RAM and the CPU.

• Cache memory is used to reduce the average time to access data from the Main memory.

• The cache is smaller in size. Memory ranges from 2KB to a few MB generally.

• The cache is a smaller and faster memory which stores copies of the data from frequently used main
memory locations.
Register Memory

• Register memory is the smallest and fastest memory in a computer.

• It is not a part of the main memory and is located in the CPU.

• A register temporarily holds frequently used data, instructions, and memory address that are to be used
by CPU. 

• All data is required to pass through registers before it can be processed.

• Registers hold a small amount of data around 32 bits to 64 bits.

• The speed of a CPU depends on the number and size (no. of bits) of registers that are built into the CPU.
Register Memory Types

• Register memory types are as follows

• Accumulator: 
• Stores the results of ALU.

• Without the accumulator, the results would be stored in memory and read again for other operations.

• Accumulator allows the ALU results to be stored in a register so it can be quickly accessed again

• Memory Address Registers (MAR): 


It holds the address of the location to be accessed from memory. MAR and MDR (Memory Data Register) together facilitate the
communication of the CPU and the main memory. 

• Memory Data Registers (MDR): 


It contains data to be written into or to be read out from the addressed location.

• Program Counter (PC): 


Program Counter (PC) is used to keep the track of execution of the program. It contains the memory address of the next instruction to
be fetched. PC points to the address of the next instruction to be fetched from the main memory when the previous instruction has
been successfully completed.
Elements of a Computer System
Hardware CPU
• The "brain" of
the computer
•Keyboard
•Diskdrive
• Scanner
• Mouse

• Hard drive • Screen


Main Memory
• Zip-Disk • Data and • Printer
• CD-Rom instructions stored • Plotter
to, fetched from
• Tape Backup 22
Software
• Software is a set of instructions, data or programs used to operate computers and
execute specific tasks.

• Software is that part of computer that can not be touched

• A set of instructions that directs a computer’s hardware to perform a task is called a


program, or software program.

• Two types

• System Software

• Application Software
System Software
• The system software is a collection of programs designed to operate, control, and extend the processing capabilities of the
computer itself.

• System software is generally prepared by the computer manufacturers.

• These software products comprise of programs written in low-level languages (language close to and understandable to
computer), which interact with the hardware at a very basic level.

• System software serves as the interface between the hardware and the end users.

• Examples of system software are

• Operating System (Windows OS, Android, iOS)

• Device Driver

• Compilers

• Assemblers, etc.
Operating System (OS)
• An Operating System (OS) is an interface between a computer user and computer hardware.

• An operating system is a software which performs all the basic tasks like file management, memory
management, process management, handling input and output, and controlling peripheral devices such as disk
drives and printers.

• Examples of Operating Systems are

• Microsoft Windows

• Macintosh / Mac OS

• Linux

• Android OS
Why we need an Operating System?

Due to following reasons an OS is required

• OS as a platform for Application programs: 


The operating system provides a platform, on top of which, other programs, called application programs can
run. These application programs help the users to perform a specific task easily.

• Managing Input-Output unit: 


Operating System also allows the computer to manage its own resources such as memory, monitor, keyboard,
printer, etc. Management of these resources is required for effective utilization.

• Multitasking: 
Operating System manages memory and allows multiple programs to run in their own space and even
communicate with each other through shared memory.
Tasks Performed by an OS

Operating system a number of tasks some of them are:

• Processor Management:

• This deals with the management of the Central Processing Unit (CPU).The operating system
takes care of the allotment of CPU time to different processes. When a process finishes its
CPU processing after executing for the allotted time period, this is called scheduling.

• Context Switching: 

• In most multitasking OSs, multiple running processes on the system may need a change of
state in execution. Even if there are multiple processes being executed at any one point in
time, only one task is executed in the foreground, while the others are put in the background.
Tasks Performed by an OS
• Device Management: 

• The Operating System communicates with the hardware and the attached devices and maintains
a balance between them and the CPU.  

• Memory management: 

• In a computer, both the CPU and the I/O devices interact with the memory. When a program
needs to be executed it is loaded onto the main memory till the execution is completed.
Thereafter that memory space is freed and is available for other programs.

• File Management: 

• The operating system manages the files, folders, and directory systems on a computer. Any data
on a computer is stored in the form of files and the operating system keeps the information
about all of them using the File Allocation Table (FAT).
Device Drivers

System software that controls and monitors functioning of a specific device on computer is
called device driver. Each device like printer, scanner, microphone, speaker, etc. that needs to be
attached externally to the system has a specific driver associated with it. When you attach a new
device, you need to install its driver so that the OS knows how it needs to be managed.
Application software
• Application software is software that helps an end user complete tasks.

• Application software lies above the system software and is different from system software in
that it’s designed for the end use and is specific in its functionality.

• This type of software is sometimes referred to as non-essential software because it’s installed
and operated based on the user’s needs.

• Any application on a mobile phone is an example of application software.

• Examples of Application software are

• MS Word

• MS Excel

• VLC Player

• Adobe Photoshop
Programming Languages

Classification of programming languages:

1. Machine language

2. Low-level languages

3. High-level languages

31
1. Machine level languages

A computer understands only sequence of bits or 1’s and 0’s


(the smallest piece of information)

A computer program can be written using machine languages


(01001101010010010….)

• Very fast execution

• Very difficult to write and debug

• Machine specific (different codes on different machines) 32


2. Low level languages
English encrypted words instead of codes (1’s and 0’s)

More understandable (for humans)

Example: Assembly language

Requires: “Translation” from Assembly code to Machine code


Assembly
Code Machine Code
compare: 1001010101001101
cmpl #oxa,n Assembl 1110010110010100
cgt 0101010111010010
end_of_loop
er
0110100110111011
acddl #0x1,n 1101100101010101
end_of_loop: 33
3. High level languages
Mostly machine independent

Close to natural language (English like language


keywords)
Easy to write and understand programs

Easy to debug and maintain code

Requires compilers to translate to machine code

Slower than low-level languages

34
3. High level languages

Some Popular High-Level languages

• COBOL (COmmon Business Oriented Language)

• FORTRAN (FORmula TRANslation)

• BASIC (Beginner All-purpose Symbolic Instructional Code)

• Pascal (named for Blaise Pascal)

• Ada (named for Ada Lovelace)

• C (whose developer designed B first)

• Visual Basic (Basic-like visual language by Microsoft)

• C++ (an object-oriented language, based on C)

• Java 35
Binary Units

36
Evolution of Programming Languages
• Early computers programmed in machine languages

• All binary numbers

• Assembly language used mnemonic codes

• Codes translated
into machine
language by a
program called
the "assembler"

37
Evolution of Programming Languages

• High level languages read like combination of English and


algebra #include <iostream>
using namespace std;
int main()
{
cout << "My first C++ program." << endl;
return 0;
}

38
Processing a High-Level Language Program
1. Source program created with an editor
2. Source code translated into machine
language by compiler
results in a .obj file (object code)

3. Linker combines common library routines


with object code
Results in a .exe file (executable code)

4. Loader brings executable code into memory


and it is run
39
Processing a High-Level Language Program

40

You might also like