FNNC LNQMHMF
+1
GOOD MORNING
-1
HPPE NPSOJOH
PPS
Subject: Programming for Problem Solving
Syllabus
By: Vishal M. Patel
Assistant Professor
CSE and IT Department
SVMIT-Bharuch
Chapter 1
Introduction to Computer and
Programming
Reference Book:
What is a Computer?
• Computer
– An electronic device which is capable of receiving information (data) in
a particular form and of performing a sequence of operations in
accordance with a predetermined but variable set of instructions
(program) to produce a result in the form of information or signals.
• Hardware
– Various devices comprising a computer
– Keyboard, screen, mouse, disks, memory, CD-ROM, and processing
units
• Software
– Programs that run on a computer
Computer Organization
• Six logical units in every computer:
– Input unit
• Obtains information from input devices (keyboard, mouse)
– Output unit
• Outputs information (to screen, to printer, to control other devices)
– Memory unit
• Rapid access, low capacity, stores input information
– Arithmetic and logic unit (ALU)
• Performs arithmetic calculations and logic decisions
– Central processing unit (CPU)
• Supervises and coordinates the various components of the computer
– Secondary storage unit
• Cheap, long-term, high-capacity storage
• Stores inactive programs
Basic Block Diagram of Computer
A Computer Consists of
• A central processing unit (CPU) consists of
– an arithmetic/logic unit (ALU) where mathematical and logic
operations are performed,
– a control unit which directs most operations by providing
timing and control signals,
– and registers that provide short-term data storage and
management facilities.
• A memory unit that stores instructions and data, and
• Input (e.g. keyboard, mouse, microphone, disk drive, etc.) and
output (e.g. monitor, status indicator lights, speakers, disk drive,
etc.) units that are used to transmit data into and out of the
computer.
ALU
• The type of operation that the ALU needs to perform is
determined by signals from the control unit .
• The data can come either from the input unit, or from the
memory unit.
• Results of the operation can either be transferred back to
the memory unit or directly to the output unit .
The memory unit or
Random access memory (RAM) -
• Stores instructions and/or data.
• Memory is divided into an array of "boxes" each
containing a byte of information.
– A byte consists of 8 bits.
– A bit (binary digit) is either 0 (OFF) or 1 (ON).
– The memory unit also serves as a storage for
intermediate and final results of arithmetic operations.
Control signal (a read or a write operation).
Control Unit
• Contains logic and timing circuits that generate the appropriate
signals necessary to execute each instruction in a program.
• It fetches an instruction from memory by sending an address
(G) and
• a read command (F) to the memory unit.
• The instruction word(s) stored at the memory location
specified by the address is then transferred to the control unit
(K).
• After decoding this instruction, the control unit transmits the
appropriate signals to the other units in order to execute the
specified operation.
• This sequence of fetch and execute is repeated by the control
unit until the computer is either powered off or reset.
Common Softwares
• Operating System
• Compilers
• Assemblers
• Interpreters
Operating System
• Definition: An operating system is a software
than manages hardware resources of computer.
• An interface between the hardware and the user.
• Provides an easy and efficient use of the system
resources.
• For Example:
Programming Language :
Definition
• A vocabulary and set of grammatical rules for
instructing a computer to perform specific tasks.
Evolution of Programming languages
– First Generation : Machine languages
• Strings of numbers giving machine specific instructions
– Second Generation : Assembly languages
• English-like abbreviations representing elementary computer operations
(translated via assemblers)
– Example:
LOAD BASEPAY
ADD OVERPAY
STORE GROSSPAY
– Third Generation : High-level languages
• Codes similar to everyday English
• Use mathematical notations (translated via compilers)
• Example: grossPay = basePay + overTimePay
PL hierarchy
What does the computer
understand?
• Computer only understands machine
language instructions.
Assembler
• Instructions written in assembly language
must be translated to machine language
instructions :
– Assembler does this
• One to one translation : One AL instruction
is mapped to one ML instruction.
• AL instructions are CPU specific.
Compiler
• Instructions written in high-level language also
must be translated to machine language
instructions :
– Compiler does this
• Generally one to many translation : One HL
instruction is mapped to many ML instruction.
• HL instructions are not CPU specific but compiler
is.
Interpreter
• An interpreter translates high-level instructions
into an intermediate form, which it then executes.
In contrast, a compiler translates high-level
instructions directly into machine language.
• Compiled programs generally run faster than
interpreted programs.
Algorithm and Flowchart