0% found this document useful (0 votes)
1 views27 pages

Introduction

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 27

INTRODUCTION TO COMPUTER

AND PROGRAMMING
Introduction:

• Computer: A computer is a programmable machine. The two principal characteristics of


a computer are: It responds to a specific set of instructions in a well-defined manner
and it can execute a pre-recorded list of instructions (a program).
• A computer is a device that can be instructed to carry out an arbitrary set of
arithmetic or logical operations automatically. Their ability to follow a sequence of
operations, called a program, make computers very flexible and popular.
• Conventionally, a modern computer consists of at least one processing element,
typically a central processing unit (CPU), and some form of memory. The
processing element carries out arithmetic and logic operations, and a sequencing
and control unit can change the order of operations in response to stored
information.
Block diagram and basic components of a
computer
 It includes all physical components which are touchable and sensible. It is mainly
divided into 4 parts - CPU, input device, output device and auxiliary memory.
 CPU is the Central Processing Unit, which contains electronics circuits and used to
execute instructions and also controls the operations of other input output devices. CPU
is again divided into three parts ALU, CU, and memory.
 ALU (Arithmetic and Logical Unit) performs arithmetical operations like
addition, subtraction, multiplication, division as well as logical operations like
AND, OR, NOT operations.
 CU (Control Unit) controls each and every activity of processing of all
connected devices. It acts as a brain. Its main function is to fetch instructions from
main memory and execute it. Normally it executes instructions sequentially. But
again this depends on specified instructions.
 Memory is also called as a main memory or primary memory or internal memory.
It is mainly used to store instructions or information in the form of zero’s and one’s.
Control unit fetches instructions from the main memory. This memory is also
called as a semiconductor memory because it is constructed by the semiconductor
material like silicon. This memory is again divided into various types that are
RAM, ROM, PROM, EPROM, and EEPROM.
 RAM (Random Access Memory) can hold data till power is on. So it is called as a
volatile memory (that means temporary memory).
 ROM (Read Only Memory) can hold data permanently. Ordinary user cannot store his
information into the ROM only manufacturer of the ROM chip can store data into it. It
consists of programs which can control IO devices (BIOS), booting procedures,
programs of some mathematical functions like sin, cos, tan etc. So it is called as a
nonvolatile memory (that means permanent memory).
 PROM (Programmable Read Only Memory) can hold data permanently. Programmer
can store his information into the PROM but only once. After that modification is not
allowed. So it is called as a nonvolatile memory (that means permanent memory).
 EPROM (Erasable Programmable Read Only Memory) can hold data permanently. User
can store his information into the EPROM but only once. After that bit modification is
not allowed. User can delete all the contents of the chip using ultra violet rays and again
rewrite information on the EPROM chip. So it is called as a nonvolatile memory (that
means permanent memory).
 EEPROM (Electrically Erasable Programmable Read Only Memory) can hold data
permanently. User can store information into the EEPROM and bit modification is
allowed. So it is called as a nonvolatile memory (that means permanent memory). But
till now it is not used as a secondary memory because of its cost.
 CPU accepts information from user through input device. There are many input devices
like keyboard, mouse, mice, tracker ball, touch screens etc.
 CPU conveys information to user through output device. There are many output devices
like monitor, LCD, printers, plotters, speakers etc.
 Auxiliary memory is also called as a secondary memory or external memory or
magnetic memory. This is permanent memory. User can store data (programs or
documents or pictures etc.) permanently on this type of memory. It can be modified.
There are many types of secondary memory. That are hard disk, floppy disk, CDROM,
pen drive etc.
Computer hardware and software
Computer hardware includes all the electrical, mechanical, and the electronic parts of a
computer. Any part that we can see or touch is the hard ware. Computer hardware includes
System Unit, Peripheral devices, Input devices i.e. keyboard, mouse etc., Output devices i.e.
Display Unit, printer etc., Storage devices like hard disk, floppy disks etc.
• Physical parts of the computer are called hardware.
1.You can touch, see and feel hardware.
2.Hardware is constructed using physical materials or components.
3.Computer is hardware, which operates under the control of software.
4.If hardware is damaged, it is replaced with new one.
5.Hardware is not affected by computer viruses.
6.Hardware cannot be transferred from one place to another electronically through
network.
7.User cannot make new duplicate copies of the hardware.
Software: The functioning of the computer is not dependent on hardware alone. So, what
else is required? It requires a set of instructions that tells the computer what is to be done
with the input data. In computer terminology, this set of instructions is called a program
and one or more programs is termed as software.
1.A set of instructions given to the computer is called software.
2.You cannot touch and feel software.
3.Software is developed by writing instructions in programming language.
4.The operations of computer are controlled through software.
5.If software is damaged or corrupted, its backup copy can be reinstalled.
6.Software is affected by computer viruses.
7.Software can be transferred from one place to another electronically through network.
8.User can make many new duplicate copies of the software.
Types of Software
Concepts of Machine level, assembly level and
High level programming
Machine Level Language
• The fundamental language of the computer’s processor, also called Low Level Language.
• All programs are converted into machine language before they can be executed.
• Consists of combination of 0’s and 1’s that represent high and low electrical voltage.
• Machine code is the only language a computer can process directly without a previous
transformation.
• Currently, programmers almost never write programs directly in machine code, because it requires
attention to numerous details that a high-level language handles automatically. True machine code
is a stream of raw, usually binary, data.

Assembly level language


• A low level language that is similar to machine language.
• Uses symbolic operation code to represent the machine operation code.
• An assembly language contains the same instructions as a machine language, but the instructions
and variables have names instead of being just numbers.
High Level Language

• Computer (programming) languages that is easier to learn as it uses English like


statements. Examples are C ++, Visual Basic, Pascal, Fortran etc.
• High-level language refers to the higher level of abstraction from machine language.
• Rather than dealing with registers, memory addresses and call stacks, high-level
languages deal with variables, arrays, objects, complex arithmetic or Boolean
expressions, subroutines and functions, loops, e t c .
Compiler and Interpreter
• A high-level language is one which is understandable by us humans.
• It contains words and phrases from the English (or other) language.
• But a computer does not understand high-level language. It only understands
program written in 0's and 1's in binary, called the machine code.
• A program written in high-level language is called a source code. We need to
convert the source code into machine code and this is accomplished my compilers
and interpreters. Hence, a compiler or an interpreter is a program that converts
program written in high-level language into machine code understood by the
computer.
Compiler
• A compiler is a computer program that reads a program written in a high-level language
such as C, C++, FORTRAN, COBOL, etc. It can translate it into the same program in a
low-level language including machine language. The compiler also finds out the
various errors encountered during the compilation of a program.
• The compiler converts high-level language into low-level language using various phases.
• A character stream inputted by the customer goes through multiple stages of compilation
which at last will provide target language.
Advantages of Compiler
 A compiler translates a program in a single run.
 It consumes less time.
 CPU utilization is more.
 Both syntactic and semantic errors can be checked concurrently.
 It is easily supported by many high-level languages like C, C++, JAVA, etc.
Interpreter
• An interpreter is a program that executes the programming code directly instead of just
translating it into another format.
• It translates and executes programming language statements one by one.
• An interpreter takes less time to interpret a source program as distinguished by a
compiler.

Advantages of Interpreter

 An interpreter translates the program line by line.


 The interpreter is smaller in size.
 It is flexible.
 Error localization is easier.
 The interpreter facilitates the implementation of computer programming language
constructs.
Algorithm
• An algorithm is the finite set of sequential instructions to accomplish a task, where
instructions are written in the natural languages like English. It is also called as a step by step
solution of the problem.
• Properties/Characteristics of the Algorithm:
 Definiteness: Each step of algorithm must be clear and unambiguous.
 Effectiveness: Every step must be basic and essential.
 Input and output: The algorithm must accept zero or more input and must produce at
least one output.
• Advantages:
 Very easy to write.
 Easy technique to understand logic.
 Easy identification of the mistakes by non computer person.
• Disadvantages:
 Time consuming.
 Difficult to show branching and looping.
 Big tasks are difficult to put in algorithm.
Write an algorithm to check whether the given
number is positive or negative.
Algorithm
• Step-1 : Accept the number i.e. n
• Step-2 : Check if n<0 ? If yes go to Step 3 otherwise go to Step 5
• Step-3 : Print n is negative
• Step-4 : Stop procedure
• Step-5 : Print n is positive
Flowcharts
• A Flowchart is graphical or diagrammatical representation of sequence of any
problem to be solved by computer programming language.
• It is drawn before writing any program.
• Through flowchart it is easy to understand the logic and sequence of problem.
• After drawing flowchart it becomes easy to write any program.

18
Flowchart symbols

19
Flowchart for addition of two numbers

20
Decision flow chart

21
Flowchart to find large number from two numbers

22
Flowchart to find large number among three
numbers
Looping flow chart

24
Flowchart for sum of 1 to 50 numbers

25
Draw a flowchart to calculate area of
rectangle.
Draw a flowchart to check whether given
number is prime or not.

You might also like