You are on page 1of 28

LOGIC BUILDING

TECHNIQUES
Unit 1 : Introduction To
Computer System &
Programming ,
Algorithms
• Basic Terminologies: Program, Software, Operating System, I/O Devices,
Process. Brief about computer systems, Basics of Number System, basic
structure of simple programming, Understanding program development cycle.
• Basics of Algorithm: Introduction to Algorithms, Characteristics of
Algorithms, Algorithm Notation, Merits & Demerits of Algorithms.

Prepared by : Ms. Aditi Mehta 3


WHAT IS COMPUTER ?
A computer is a programmable machine or device that performs pre-defined or programmed computations
or controls operations that are expressible in numerical or logical terms at high speed and with great
accuracy.

Or

A computer is a digital electronics machine that can be programmed to carry out sequences of arithmetic or
logical operation automatically.

Or

Programmable machine designed to perform arithmetic and logical operation automatically and
sequentially as inputs given by users .

Prepared by : Ms. Aditi Mehta 4


WHAT IS COMPUTER PROGRAM?
• A computer program is a sequence or set of instruction in a programming language for a computer to
execute. Computer programs are one component of software which also include documentation and
other intangible components.

WHAT IS COMPUTER SYSTEM?


• Computer System= Hardware + Software + User

• Computer system is made up of three main components :

a. Hardware = Internal devices + Peripheral devices : All physical part of the computer (or everything we
can touch) are known as hardware.

b. Software = Programs : Software gives “intelligence” to the computer.

c. User : Person who operate computer

Prepared by : Ms. Aditi Mehta 5


WHAT IS SOFTWARE?
• Software is a set of instructions, data or programs used to operate computers and execute specific tasks.
For example, MS PAINT, ORACLE, JAVA, WINDOWS OPERATING SYSTEM etc. Software is
computer instructions that tell the hardware what to do. Software is programs, which are instruction sets
written by programmers.

• Types of Software:

a. Application Software: - Application software directs the computer to execute commands given by the
user and may be said to include any program that processes data for a user. For example, word
processors, spreadsheets, database management, inventory and payroll programs etc.

b. System Software: - System software is a type of computer program that is designed to run a
computer’s hardware and application programs. System software comprises the programs that you use
to manage your computer, including operating systems such as Windows, Linux, or UNIX for larger
computers and Google Android and Apple iOS for smartphones.

Prepared by : Ms. Aditi Mehta 6


WHAT IS HARDWARE?
• Hardware is the equipment, or the physical devices, associated with a computer. For example,
keyboards, mice, speakers, and printers are all hardware. Hardware is the physical parts of a computer,
such as the processor, memory modules and the screen.

Prepared by : Ms. Aditi Mehta 7


WHAT IS OPERATING SYSTEM?
• An operating system (OS) is system software that manages computer hardware and software resources
and provides common services for computer programs. The Operating System is often described as a
translator; it translates the language of the hardware (binary numbers) into the language of the software
(written programs) and then displays it in a way that humans can understand (text, images and sound).

Prepared by : Ms. Aditi Mehta 8


WHAT IS INPUT DEVICES?
• An input device is a piece of hardware used to provide data to a computer used for interaction and
control. It allows the input of raw data to the computer for processing. Inputs are any devices that send
information into the computer. For example, a mouse has a position on the screen and is able to tell the
computer when a button is clicked and which button is clicked. A keyboard is able to send key presses to
the computer.

Prepared by : Ms. Aditi Mehta 9


WHAT IS OUTPUT DEVICES?
• Outputs are any devices that are able to show information to the user. Good examples of these are the
screen, which shows the user text and images, and headphones, which are able to play sounds for the
user to listen to.

Prepared by : Ms. Aditi Mehta 10


WHAT IS CPU?
• A Central Processing Unit is also called a processor, central processor, or microprocessor. It carries
out all the important functions of a computer. It receives instructions from both the hardware and active
software and produces output accordingly. It stores all important programs like operating systems and
application software. CPU also helps Input and output devices to communicate with each other. Owing
to these features of CPU, it is often referred to as the brain of the computer.

• The main processing device in any computer is the CPU (Central Processing Unit), which performs
binary calculations to make the computer run. This component is often referred to as the ‘brain of the
computer’.

Prepared by : Ms. Aditi Mehta 11


• Generally, a CPU has three components:

a. ALU (Arithmetic Logic Unit) : It is the arithmetic logic unit, which performs arithmetic and logical
functions. Arithmetic functions include addition, subtraction, multiplication division, and comparisons.
Logical functions mainly include selecting, comparing, and merging the data.

b. Control Unit : The control unit (CU) is a component of a computer's central processing unit (CPU) that
directs the operation of the processor. It tells the computer's memory, arithmetic/logic unit and input and
output devices how to respond to the instructions that have been sent to the processor.

c. Memory or Storage Unit : It is called Random access memory (RAM). It temporarily stores data,
programs, and intermediate and final results of processing. So, it acts as a temporary storage area that
holds the data temporarily, which is used to run the computer.

Prepared by : Ms. Aditi Mehta 12


WHAT IS STORAGE DEVICES?
• A storage device is any type of computing hardware that is used for storing, porting or extracting data
files and objects. Storage devices can hold and store information both temporarily and permanently.
They may be internal or external to a computer, server or computing device.

Prepared by : Ms. Aditi Mehta 13


STORAGE UNIT

Prepared by : Ms. Aditi Mehta 14


DIFFERENCE BETWEEN VOLATILE & NON-VOLATILE MEMORY

S. No. Volatile Memory Non-Volatile Memory

Volatile memory is the type of memory in which data is lost Non-volatile memory is the type of memory in which data
1.
as it is powered-off. remains stored even if it is powered-off.

2. Contents of Volatile memory are stored temporarily. Contents of Non-volatile memory are stored permanently.

3. It is faster than non-volatile memory. It is slower than volatile memory.

RAM(Random Access Memory) is an example of volatile ROM(Read Only Memory) is an example of non-volatile
4.
memory. memory.

In volatile memory, data can be easily transferred in In non-volatile memory, data can not be easily transferred in
5.
comparison to non-volatile memory. comparison to volatile memory.

6. In Volatile memory, process can read and write. In Non-volatile memory, process can only read.

Non-volatile memory generally has more storage capacity than


7. Volatile memory generally has less storage capacity.
volatile memory.

Prepared by : Ms. Aditi Mehta 15


In volatile memory, the program’s data are stored which are In non-volatile memory, any kind of data which has to be
8.
currently in process by the CPU. saved permanently are stored.

9. Volatile memory is more costly per unit size. Non-volatile memory is less costly per unit size.

Volatile memory has a huge impact on the system’s Non-volatile memory has a huge impact on a system’s storage
10.
performance. capacity.

In non-volatile memory, processor has no direct access to


11. In volatile memory, processor has direct access to data.
data.

Volatile memory chips are generally kept on the memory


12. Non-volatile memory chips are embedded on the motherboard.
slot.

Advantages-
Advantages-
•More reliable
•Fast speed
13. •Stores data permanently
•Low power consumption
•Inexpensive memory
•Better system performance as it increases speed
•Helps in booting of operating system

Disadvantages-
Disadvantages-
•Expensive
14. •Slow speed
•Limited storage space
•Can only read data
•Stores data temporarily

Prepared by : Ms. Aditi Mehta 16


WHAT IS PROGRAM DEVELOPMENT LIFE CYCLE?
• Program development is the process of creating application programs. Program development life
cycle (PDLC) contains five phases of program development: analyzing, designing, coding, debugging
and testing, and implementing and maintaining application software.

Prepared by : Ms. Aditi Mehta 17


• The following are six steps in the Program Development Life Cycle:

1. Analyze the problem. The computer user must figure out the problem, then decide how to resolve the
problem - choose a program.
2. Design the program. A flow chart is important to use during this step of the PDLC. This is a visual
diagram of the flow containing the program. This step will help you break down the problem.
3. Code the program. This is using the language of programming to write the lines of code. The code is
called the listing or the source code. The computer user will run an object code for this step.
4. Debug the program. The computer user must debug. This is the process of finding the "bugs" on the
computer. The bugs are important to find because this is known as errors in a program.
5. Formalize the solution. One must run the program to make sure there are no syntax and logic errors.
Syntax are grammatical errors and logic errors are incorrect results.
6. Document and maintain the program. This step is the final step of gathering everything together.
Internal documentation is involved in this step because it explains the reasoning one might of made a
change in the program or how to write a program.

Prepared by : Ms. Aditi Mehta 18


WHAT IS COMPILATION PROCESS?
• After a computer program is typed using programming language statements and stored in memory, it
must be translated to machine language that represents the millions of on/off circuits within the
computer.

• Your programming language statements are called source code, and the translated machine language
statements are object code.

• Each programming language uses a piece of software, called a compiler or an interpreter, to translate
your source code into machine language.

• Machine language is also called binary language, and is represented as a series of 0s and 1s.

• After a program’s source code is successfully translated to machine language, the computer can carry
out the program instructions. When instructions are carried out, a program runs, or executes. In a typical
program, some input will be accepted, some processing will occur, and results will be output

Prepared by : Ms. Aditi Mehta 19


WHAT IS COMPILATION PROCESS IN C LANGUAGE?
• The compilation is a process of converting the source code into object code.

• It is done with the help of the compiler. The compiler checks the source code for the syntactical or
structural errors, and if the source code is error free, then it generates the object code.

• The c compilation process converts the source code taken as input into the object code or machine code.
The compilation process can be divided into four steps, i.e., Pre-processing, Compiling, Assembling,
and Linking.

Prepared by : Ms. Aditi Mehta 20


1. Preprocessor : The source code is the code which is written in a text editor and the source code file is given an
extension ".c". This source code is first passed to the preprocessor, and then the preprocessor expands this code.
After expanding the code, the expanded code is passed to the compiler. In a preprocessing process all the
comments line will be removed because it is for use not for machine. In this step macro expansion is done. The
preprocessor creates an intermediate file where some pre-written assembly level instructions replace the defined
constant or expression. In this steps file inclusion process is also done by #include statements.

2. Compiler : The code which is expanded by the preprocessor is passed to the compiler. The compiler converts
this code into assembly code. Or we can say that the C compiler converts the pre-processed code into assembly
code. In this phase compiler gives the information about any syntax error or warning available in your code.

3. Assembler : The assembly code is converted into object code by using an assembler. The name of the object file
generated by the assembler is the same as the source file. The extension of the object file in DOS is '.obj,' and in
UNIX, the extension is 'o'. If the name of the source file is 'hello.c', then the name of the object file would be
'hello.obj'. Here assembly level code is converted into a machine understandable code that in binary code using
an assembler. It is prewritten program that translate assembly code into machine code.

4. Linker : A Linker is a computer program that takes one or more object files generated by a compiler and
combines them into one, executable program. The linker is to link the object code of our program with the
object code of the library files and other files. The output of the linker is the executable file. The name of the
executable file is the same as the source file but differs only in their extensions. In DOS, the extension of the
executable file is '.exe', and in UNIX, the executable file can be named as 'a.out'.

Prepared by : Ms. Aditi Mehta 21


WHAT IS ALGORITHM?
• An algorithm is a sequence of well-defined instructions for completing a task or solving a problem. An
algorithm is that it contains the finite set of instructions which are being carried in a specific order to
perform the specific task. It is not the complete program or code; it is just a solution (logic) of a
problem, which can be represented either as an informal description using a Flowchart or Pseudocode.

Prepared by : Ms. Aditi Mehta 22


Algorithm Examples :

1. Convert from one unit to another. (feet, yards, kilometers, miles)

2. Find square of Number.

3. Print total income from items sold in the week.

4. Multiplication of numbers entered by the user.

5. Sort a list of names in alphabetical order.

6. Quickly Find name in list.

7. Merging of list.

8. Find highest number from 2 numbers.

Prepared by : Ms. Aditi Mehta 23


Characteristics or properties of Algorithm

1. Precision – The steps are precisely stated (defined).

2. Uniqueness – Results of each step are uniquely defined and only depend on the input and the result of
the preceding steps.

3. Finiteness – The algorithm stops after a finite number of instructions are executed.

4. Input – The algorithm receives input.

5. Output – The algorithm produces output.

6. Generality – The algorithm applies to a set of inputs.

Prepared by : Ms. Aditi Mehta 24


Guidelines/Notation for Developing an Algorithm

Following guidelines must be followed while developing an algorithm:

1. An algorithm will be enclosed by START (or BEGIN) and STOP (or END).

2. To accept data from user, generally used statements are INPUT, READ, GET or OBTAIN.

3. To display result or any message, generally used statements are PRINT, DISPLAY, or WRITE.

4. Generally, COMPUTE or CALCULATE is used while describing mathematical expressions and based
on situation relevant operators can be used.

Prepared by : Ms. Aditi Mehta 25


Advantages of Algorithm

1. It is a stepwise representation of a solution to a given problem, which makes it easy to understand.

2. An algorithm uses a definite procedure.

3. It is not dependent on any programming language, so it is easy to understand for anyone even without
programming knowledge.

4. Every step in an algorithm has its own logical sequence so it is easy to debug.

5. By using algorithm, the problem is broken down into smaller pieces or steps hence, it is easier for
programmer to convert it into an actual program.

Disadvantages of Algorithm

6. Algorithm is Time consuming.

7. Difficult to show Branching and Looping in Algorithms.

8. Big tasks are difficult to put in Algorithms.

Prepared by : Ms. Aditi Mehta 26


Algorithm 1: Algorithm to convert temperature from Fahrenheit to Celsius.

Input: F

Output: C

F: temperature in Fahrenheit

C: temperature in Celsius.

Step 1: Start.

Step 2: Read temperature (Fahrenheit) in F.

Step 3: calculate C=(5(F-32))/9.

Step 4: Display C as temperature in Celsius.

Step 5: Stop.

Prepared by : Ms. Aditi Mehta 27


Algorithm 2: Sum of two numbers

Input : A,B

Output : Sum

A : First number

B : Second number

Sum : Addition of both number

Step 1: Start

Step 2: Input first number in A

Step 3: Input second number in B

Step 4: Sum=A+B

Step 5: Display value of sum

Step 6: Stop
Prepared by : Ms. Aditi Mehta 28

You might also like