0% found this document useful (0 votes)
24 views19 pages

Unit-1 Study Material PDF

Programming involves writing computer programs to solve problems. A computer program is a set of instructions that tells the computer what tasks to perform. There are two main types of computer software: system software and application software. System software includes the operating system, language processors like compilers and interpreters, and device drivers. It allows the computer hardware and applications to work together. Application software performs specific tasks for users like word processing, web browsing, and games. Programming allows humans to utilize computers to process data, perform calculations, and output useful information by writing instructions in programming languages.

Uploaded by

varunk060504
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)
24 views19 pages

Unit-1 Study Material PDF

Programming involves writing computer programs to solve problems. A computer program is a set of instructions that tells the computer what tasks to perform. There are two main types of computer software: system software and application software. System software includes the operating system, language processors like compilers and interpreters, and device drivers. It allows the computer hardware and applications to work together. Application software performs specific tasks for users like word processing, web browsing, and games. Programming allows humans to utilize computers to process data, perform calculations, and output useful information by writing instructions in programming languages.

Uploaded by

varunk060504
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/ 19

PROGRAMMING FOR PROBLEM SOLVING

UNIT-1
INTRODUCTION TO PROGRAMMING:-
Before we understand what programming is, you must know what a computer is. A computer is a device that
can accept human instruction processes it and responds to it or a computer is a computational device which is
used to process the data under the control of a computer program. Program is a sequence of instruction along
withdata.

The basic components of a computer are:


1. Input unit
2. Central Processing Unit(CPU)
3. Output unit

The CPU is further divided into three parts-


 Memory unit
 Control unit
 Arithmetic Logic unit

Most of us have heard that CPU is called the brain of our computer because it accepts data, provides
temporary memory space to it until it is stored (saved) on the hard disk, performs logical operations on it and
hence processes (here also means converts) data into information. We all know that a computer consists of
hardware and software. Software is a set of programs that performs multiple tasks together. An operating
system is also software (system software) that helps humans to interact with the computer system.

WHAT IS PROGRAMMING:-
A program is a set of instructions given to a computer to perform a specific operation. or computer is a
computational device which is used to process the data under the control of a computer program. While
executing the program, raw data is processed into a desired output format. These computer programs are
written in programming languages which are high level languages.

AMIT AWASTHI SIR


(Assistant Professor)
PROGRAMMING FOR PROBLEM SOLVING

AMIT AWASTHI SIR


(Assistant Professor)
PROGRAMMING FOR PROBLEM SOLVING
COMPUTER HARDWARE:- Input-Process-Output Model
Computer input is called data and the output obtained after processing it, based on user’s instructions is
called information. Raw facts and figures which can be processed using arithmetic and logical operations to
obtain information are called data.

The processes that can be applied to data are of two types −


 Arithmetic operations − Examples include calculations like addition, subtraction, differentials, square
root, etc.
 Logical operations − Examples include comparison operations like greater than, less than, equal to,
opposite, etc.
The corresponding figure for an actual computer looks something like this −

The basic parts of a computer are as follows −


 Input Unit − Devices like keyboard and mouse that are used to input data and instructions to the
computer are called input unit.
 Output Unit − Devices like printer and visual display unit that are used to provide information to the
user in desired format are called output unit.
 Control Unit − as the name suggests, this unit controls all the functions of the computer. All devices or
parts of computer interact through the control unit.
 Arithmetic Logic Unit − this is the brain of the computer where all arithmetic operations and logical
operations take place.
AMIT AWASTHI SIR
(Assistant Professor)
PROGRAMMING FOR PROBLEM SOLVING
 Memory − All input data, instructions and data interim to the processes are stored in the memory.
Memory is of two types – primary memory and secondary memory. Primary memory resides within
the CPU whereas secondary memory is external to it.

Characteristics of Computer
To understand why computers are such an important part of our lives, let us look at some of its characteristics −

 Speed − typically, a computer can carry out 3-4 million instructions per second.

 Accuracy − Computers exhibit a very high degree of accuracy. Errors that may occur are usually due to
inaccurate data, wrong instructions or bug in chips – all human errors.

 Reliability − Computers can carry out same type of work repeatedly without throwing up errors due to tiredness
or boredom, which are very common among humans.

 Versatility − Computers can carry out a wide range of work from data entry and ticket booking to complex
mathematical calculations and continuous astronomical observations. If you can input the necessary data with
correct instructions, computer will do the processing.

 Storage Capacity − Computers can store a very large amount of data at a fraction of cost of traditional storage
of files. Also, data is safe from normal wear and tear associated with paper.

AMIT AWASTHI SIR


(Assistant Professor)
PROGRAMMING FOR PROBLEM SOLVING
COMPUTER SOFTWARE:-
The hardware devices need user instructions to function. A set of instructions that achieve a single outcome
are called program or procedure. Many programs functioning together to do a task make a software.

For example, a word-processing software enables the user to create, edit and save documents. A web
browser enables the user to view and share web pages and multimedia files. There are two categories of
software −

 System Software

 Application Software

 Utility Software

Let us discuss them in detail.

AMIT AWASTHI SIR


(Assistant Professor)
PROGRAMMING FOR PROBLEM SOLVING
System Software
Software required to run the hardware parts of the computer and other application software are called system
software. System software acts as interface between hardware and user applications. An interface is
needed because hardware devices or machines and humans speak in different languages.

Machines understand only binary language i.e. 0 (absence of electric signal) and 1 (presence of electric
signal) while humans speak in English, French, German, Tamil, Hindi and many other languages. English is
the pre-dominant language of interacting with computers. Software is required to convert all human
instructions into machine understandable instructions. And this is exactly what system software does.

Based on its function, system software is of four types −

 Operating System

 Language Processor

 Device Drivers

Operating System

System software that is responsible for functioning of all hardware parts and their interoperability to carry out
tasks successfully is called operating system (OS). OS is the first software to be loaded into computer
memory when the computer is switched on and this is called booting. OS manages a computer’s basic
functions like storing data in memory, retrieving files from storage devices, scheduling tasks based on priority,
etc.

Language Processor

As discussed earlier, an important function of system software is to convert all user instructions into machine
understandable language. When we talk of human machine interactions, languages are of three types −

 Machine-level language –

This language is nothing but a string of 0s and 1s that the machines can understand. It is completely
machine dependent.

 Assembly-level language –

This language introduces a layer of abstraction by defining mnemonics. Mnemonics are English like
words or symbols used to denote a long string of 0s and 1s. For example, the word “READ” can be
defined to mean that computer has to retrieve data from the memory. The complete instruction will
also tell the memory address. Assembly level language is machine dependent.

AMIT AWASTHI SIR


(Assistant Professor)
PROGRAMMING FOR PROBLEM SOLVING
 High level language –

This language uses English like statements and is completely independent of machines. Programs
written using high level languages are easy to create, read and understand.

Program written in high level programming languages like Java, C++, etc. is called source code. Set of
instructions in machine readable form is called object code or machine code. System software that
converts source code to object code is called language processor. There are three types of language
interpreters−

 Assembler − Converts assembly level program into machine level program.

 Interpreter − Converts high level programs into machine level program line by line.

 Compiler − Converts high level programs into machine level programs at one go rather than line by
line.

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
Software that performs a single task and nothing else is called application software. Application software is
very specialized in their function and approach to solving a problem. So spreadsheet software can only do
operations with numbers and nothing else. A hospital management software will manage hospital activities
and nothing else. Here is some commonly used application software −

 Word processing
 Spreadsheet
 Presentation
 Database management
 Multimedia tools

Utility Software
Application software that assist system software in doing their work is called utility software. Thus utility
software is actually a cross between system software and application software. Examples of utility software
include −

 Antivirus software
 Disk management tools
 File management tools
AMIT AWASTHI SIR
(Assistant Professor)
PROGRAMMING FOR PROBLEM SOLVING
 Compression tools
 Backup tools

AMIT AWASTHI SIR


(Assistant Professor)
PROGRAMMING FOR PROBLEM SOLVING

WHERE THE PROGRAM IS STORED AND EXECUTED:-

AMIT AWASTHI SIR


(Assistant Professor)
PROGRAMMING FOR PROBLEM SOLVING

AMIT AWASTHI SIR


(Assistant Professor)
PROGRAMMING FOR PROBLEM SOLVING

AMIT AWASTHI SIR


(Assistant Professor)
PROGRAMMING FOR PROBLEM SOLVING

AMIT AWASTHI SIR


(Assistant Professor)
PROGRAMMING FOR PROBLEM SOLVING
WHAT IS COMPILER:-
A compiler is a special program that processes statements written in a particular programming language
and turns them into machine language or "code" that a computer's processor uses.

WHAT IS ALGORITHAM? ALGORITHAM BASICS


The word Algorithm means “a process or set of rules to be followed in calculations or other problem-solving
operations”. Therefore Algorithm refers to a set of rules/instructions that step-by-step define how a work is to
be executed upon in order to get the expected results.

It can be understood by taking an example of cooking a new recipe. To cook a new recipe, one reads the
instructions and steps and executes them one by one, in the given sequence. The result thus obtained is the
new dish cooked perfectly. Similarly, algorithms help to do a task in programming to get the expected output.

AMIT AWASTHI SIR


(Assistant Professor)
PROGRAMMING FOR PROBLEM SOLVING
The Algorithm designed is language-independent, i.e. they are just plain instructions that can be implemented
in any language, and yet the output will be the same, as expected.

How to Design an Algorithm?

In order to write an algorithm, following things are needed as a pre-requisite:


1. The problem that is to be solved by this algorithm.
2. The constraints of the problem that must be considered while solving the problem.
3. The input to be taken to solve the problem.
4. The output to be expected when the problem the is solved.
5. The solution to this problem, in the given constraints.

Algorithm to add 3 numbers and print their sum:


1. START

2. Declare 3 integer variables num1, num2 and num3.

3. Take the three numbers, to be added, as inputs in variables num1, num2, and num3

respectively.

4. Declare an integer variable sum to store the resultant sum of the 3 numbers.

5. Add the 3 numbers and store the result in the variable sum.

6. Print the value of variable sum

7. END

AMIT AWASTHI SIR


(Assistant Professor)
PROGRAMMING FOR PROBLEM SOLVING
REPRESENTAION OF FLOWCHART :-
A flowchart is a blueprint that pictorially represents the algorithm and its steps. The steps of a flowchart do not have a
specific size and shape rather it is designed in different shapes and sizes

Flow-Chart Symbols
The following table illustrates the symbols along with their names (used in a flow-chart) –

AMIT AWASTHI SIR


(Assistant Professor)
PROGRAMMING FOR PROBLEM SOLVING
Sample of Flow Chart:-

AMIT AWASTHI SIR


(Assistant Professor)
PROGRAMMING FOR PROBLEM SOLVING

WHAT IS PESUDO CODE & SOURCE CODE:-

Pseudo code is a STEP-BY-STEP writing outline of your code that you can gradually transcribe in to a
programming language.

Pseudo code is a term which is often used in programming and algorithm based fields. It is a methodology
that allows the programmer to represent the implementation of an algorithm

Source code is the fundamental component of a computer program that is created by a programmer. It can
be read and easily understood by a human being. When a programmer types a sequence of C programming
language statements into Windows Notepad, for example, and saves the sequence as a text file, the text file is
said to contain the source code.

AMIT AWASTHI SIR


(Assistant Professor)
PROGRAMMING FOR PROBLEM SOLVING

AMIT AWASTHI SIR


(Assistant Professor)
PROGRAMMING FOR PROBLEM SOLVING

AMIT AWASTHI SIR


(Assistant Professor)

You might also like