0% found this document useful (0 votes)
40 views15 pages

Programming Notes 1

Uploaded by

vanshrbd
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
40 views15 pages

Programming Notes 1

Uploaded by

vanshrbd
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 15

Unit-I: Introduction to Computer and Problem-Solving Methodology

Computer System, Computing Environments, Software, Types of Software and Features of


Software.
Design Tools (Algorithm, Flow-Chart, Pseudo-Code). Types and Generations of Programming
Languages. Compiler, Interpreter, Linker, Loader, Execution of Program. Develop an Algorithm
for Simple Problems.
Computer System

A computer is an electronic device that can be programmed to accept data (input), process it and
generate result (output). A computer along with additional hardware and software together is called
a computer system. A computer system primarily comprises a central processing unit (CPU),
memory, input/output devices and storage devices. All these components function together as a
single unit to deliver the desired output. A computer system comes in various forms and sizes. It
can vary from a high-end server to personal desktop, laptop, tablet computer, or a smartphone.

Figure 1.1 shows the block diagram of a computer system. The directed lines represent the
flow of data and signal between the components.

1.1.1 Central Processing Unit (CPU)

It is the electronic circuitry of a computer that carries out the actual processing and usually referred
as the brain of the computer. It is commonly called processor also. Physically, a CPU can be placed
on one or more microchips called integrated circuits (IC). The ICs comprise semiconductor
materials.

The CPU is given instructions and data through programs. The CPU then fetches the program and
data from the memory and performs arithmetic and logic operations as per the given instructions
and stores the result back to memory. While processing, the CPU stores the data as well as
instructions in its local memory called registers. Registers are part of the CPU chip and they are
limited in size and number. Different registers are used for storing data, instructions or
intermediate results. Other than the registers, the CPU has two main components — Arithmetic
Logic Unit (ALU) and Control Unit (CU). ALU performs all the arithmetic and logic operations
that need to be done as per the instruction in a program. CU controls sequential instruction
execution interprets instructions and guides data flow through the computer’s memory, ALU and
input or output devices. CPU is also popularly known as microprocessor.

1.1.2 Input Devices

The devices through which control signals are sent to a computer are termed as input devices.
These devices convert the input data into a digital form that is acceptable by the computer system.
Some examples of input devices include keyboard, mouse, scanner, touch screen, etc., Besides, we
can now enter data through voice, for example, we can use Google voice search to search the web
where we can input the search string through our voice. Data entered through input device is
temporarily stored in the main memory (also called RAM) of the computer system. For permanent
storage and future use, the data as well as instructions are stored permanently in additional storage
locations called secondary memory.

1.1.3 Output Devices

The device that receives data from a computer system for display, physical production, etc., is
called output device. It converts digital information into human understandable form. For example,
monitor projector, headphone, speaker, printer, etc.

Software

Software is a set of programs, which is designed to perform a well-defined function. A program is


a sequence of instructions written to solve a particular problem.

Till now, we have studied about the physical components or the hardware of the computer system.
But the hardware is of no use on its own. Hardware needs to be operated by a set of instructions.
These sets of instructions are referred to as software. It is that component of a computer system,
which we cannot touch or view physically. It comprises the instructions and data to be processed
using the computer hardware. The computer software and hardware complete any task together.
The software comprises a set of instructions which on execution deliver the desired outcome. In
other words, each software is written for some computational purpose. Some examples of software
include operating systems like Ubuntu or Windows 7/10, word processing tool like LibreOffice or
Microsoft Word, video player like VLC Player, photo editors like GIMP and LibreOffice draw. A
document or image stored on the hard disk or pen drive is referred to as a soft-copy. Once printed,
the document or an image is called a hard-copy.
Need of Software

The sole purpose of a software is to make the computer hardware useful and operational. A
software knows how to make different hardware components of a computer work and
communicate with each other as well as with the end-user. We cannot instruct the hardware of a
computer directly. Software acts as an interface between human users and the hardware.
Depending on the mode of interaction with hardware and functions to be performed, the software
can be broadly classified into three categories viz. (i) System software, (ii) Programming tools and
(iii) Application software.

System Software

System software is software that directly operates the computer hardware and provides the basic
functionality to the users as well as to the other software to operate smoothly. Or in other words,
system software basically controls a computer’s internal functioning and also controls hardware
devices such as monitors, printers, and storage devices, etc. It is like an interface between hardware
and user applications, it helps them to communicate with each other because hardware understands
machine language (i.e. 1 or 0) whereas user applications are work in human-readable languages
like English, Hindi, German, etc. so system software converts the human-readable language into
machine language and vice versa.

The software that provides the basic functionality to operate a computer by interacting directly
with its constituent hardware is termed as system software. A system software knows how to
operate and use different hardware components of a computer. It provides services directly to the
end user, or to some other software. Examples of system software include operating systems,
system utilities, device drivers, etc.

Features of system software:

• System Software is closer to the computer system.


• System Software is written in a low-level language in general.
• System software is difficult to design and understand.
• System software is fast in speed (working speed).
• System software is less interactive for the users in comparison to application software.

(A) Operating System

As the name implies, the operating system is a system software that operates the computer. An
operating system is the most basic system software, without which other software cannot work.
The operating system manages other application programs and provides access and security to the
users of the system. Some of the popular operating systems are Windows, Linux, Macintosh,
Ubuntu, Fedora, Android, iOS, etc.

(B) System Utilities


Software used for maintenance and configuration of the computer system is called system utility.
Some system utilities are shipped with the operating system for example disk defragmentation
tool, formatting utility, system restore utility, etc. Another set of utilities are those which are not
shipped with the operating system but are required to improve the performance of the system, for
example, anti-virus software, disk cleaner tool, disk compression software, etc.

(C) Device Drivers

As the name signifies, the purpose of a device driver is to ensure proper functioning of a particular
device. When it comes to the overall working of a computer system, the operating system does the
work. But everyday new devices and components are being added to a computer system. It is not
possible for the operating system alone to operate all of the existing and new devices, where each
device has diverse characteristics. The responsibility for overall control, operation and
management of a particular device at the hardware level is delegated to its device driver. The
device driver acts as an interface between the device and the operating system. It provides required
services by hiding the details of operations performed at the hardware level of the device. Just like
a language translator, a device driver acts as a mediator between the operating system and the
attached device.

Programming Tools

In order to get some work done by the computer, we need to give instructions which are applied
on the input data to get the desired outcome. Computer languages are developed for writing these
instructions. It is important to understand here that computers and humans understand completely
different languages. While humans are able to write programs in high-level language, computers
understand machine language. There is a continuous need for conversion from high level to
machine level language, for which translators are needed. Also, to write the instruction, code
editors (e.g., IDLE in Python) are needed. We will briefly describe here the programming
languages, language translators and program development tools.

Application Software

Software that performs special functions or provides functions that are much more than the basic
operation of the computer is known as application software. Or in other words, application
software is designed to perform a specific task for end-users. It is a product or a program that is
designed only to fulfill end-users’ requirements. It includes word processors, spreadsheets,
database management, inventory, payroll programs, etc.

Features of application software:

• An important feature of application software is it performs more specialized tasks like


word processing, spreadsheets, email, etc.
• Mostly, the size of the software is big, so it requires more storage space.
• Application software is more interactive for the users, so it is easy to use and design.
• The application software is easy to design and understand.
• Application software is written in a high-level language in general.

The system software provides the core functionality of the computer system. However, different
users need the computer system for different purposes depending upon their requirements. Hence,
a new category of software is needed to cater to different requirements of the endusers. This
specific software that works on top of the system software is termed as application software. There
are again two broad categories of application software— general purpose and customized
application software.

(A) General Purpose Software

The application software developed for generic applications, to cater to a bigger audience in
general are called general purpose software. Such ready-made application software can be used by
end users as per their requirements. For example, spreadsheet tool Calc of LibreOffice can be used
by any computer user to do calculation or to create account sheet. Adobe Photoshop, GIMP,
Mozilla web browser, iTunes, etc., fall in the category of general-purpose software.

(B) Customized Software

These are custom or tailor-made application software, that are developed to meet the requirements
of a specific organization or an individual. They are better suited to the needs of an individual or
an organization, considering that they are designed as per special requirements. Some examples of
user-defined software include websites, school management software, accounting software, etc. It
is similar to buying a piece of cloth and getting a tailor-made garment with the fitting, colour, and
fabric of our choice.

Difference between system software and application software


Difference between system software and application software

System Software Application Software

It is designed to manage the resources of the


It is designed to fulfill the requirements
computer system, like memory and process
of the user for performing specific tasks.
management, etc.

Written in a low-level language Written in a high-level language

Less interactive for the users More interactive for the users

Application software is not so important


System software plays vital role for the
for the functioning of the system, as it is
effective functioning of a system.
task specific.

It is independent of the application software


It needs system software to run.
to run.

Computing Environments

Computing environments refer to the technology infrastructure and software platforms that are
used to develop, test, deploy, and run software applications. There are several types of computing
environments, including:

In the world of technology where every tasks are performed with help of computers, these
computers have become one part of human life. Computing is nothing but process of completing
a task by using this computer technology and it may involve computer hardware and/or software.
But computing uses some form of computer system to manage, process, and communicate
information.

Computing Environments: When a problem is solved by the computer, during that computer
uses many devices, arranged in different ways and which work together to solve problems. This
constitutes a computing environment where various number of computer devices arranged in
different ways to solve different types of problems in different ways. In different computing
environments computer devices are arranged in different ways and they exchange information in
between them to process and solve problem. One computing environment consists of many
computers’ other computational devices, software and networks that to support processing and
sharing information and solving task. Based on the organization of different computer devices and
communication processes there exists multiple types of computing environments.

Types of Computing Environments: There are the various types of computing environments.
They are:

1. Personal Computing Environment: In personal computing environment there is a stand-


alone machine. Complete program resides on computer and executed there. Different
stand-alone machines that constitute a personal computing environment are laptops,
mobiles, printers, computer systems, scanners etc. That we use at our homes and offices.
2. Time-Sharing Computing Environment: In Time Sharing Computing Environment
multiple users share system simultaneously. Different users (different processes) are
allotted different time slice and processor switches rapidly among users according to it.
For example, student listening to music while coding something in an IDE. Windows 95
and later versions, Unix, IOS, Linux operating systems are the examples of this time-
sharing computing environment.
3. Client Server Computing Environment: In client server computing environment two
machines are involved i.e., client machine and server machine, sometime same machine
also serve as client and server. In this computing environment client requests
resource/service and server provides that respective resource/service. A server can provide
service to multiple clients at a time and here mainly communication happens through
computer network.
4. Distributed Computing Environment: In a distributed computing environment multiple
nodes are connected together using network but physically they are separated. A single
task is performed by different functional units of different nodes of distributed unit. Here
different programs of an application run simultaneously on different nodes, and
communication happens in between different nodes of this system over network to solve
task.
5. Grid Computing Environment: In grid computing environment, multiple computers
from different locations works on single problem. In this system set of computer nodes
running in cluster jointly perform a given task by applying resources of multiple
computers/nodes. It is network of computing environment where several scattered
resources provide running environment for single task.
6. Cloud Computing Environment: In cloud computing environment on demand
availability of computer system resources like processing and storage are availed. Here
computing is not done in individual technology or computer rather it is computed in cloud
of computers where all required resources are provided by cloud vendor. This environment
primarily comprised of three services i.e software-as-a-service (SaaS), infrastructure-as-a-
service (IaaS), and platform-as-a-service (PaaS).

ALGORITHM

An Algorithm is a step-by-step procedure to solve a given problem. The word algorithm originates
from the word ‘algorism’ which means process of doing arithmetic with Arabic numerals.

What is the need for algorithms?


1. Algorithms are necessary for solving complex problems efficiently and effectively.
2. They help to automate processes and make them more reliable, faster, and easier to
perform.
3. Algorithms also enable computers to perform tasks that would be difficult or impossible
for humans to do manually.
4. They are used in various fields such as mathematics, computer science, engineering,
finance, and many others to optimize processes, analyze data, make predictions, and
provide solutions to problems.

Characteristics of algorithm:

A well defined algorithm has the five basic characteristics; as follows

1. Input: Algorithm starts with procedural steps to accept input data. The algorithm must accept
one or more data to be processed.
2. Definite: Each operational step or operation must be definite i.e. each and every instruction
must clearly specify that what should be done.
3. Effective: Each operational step can at least in principle is carried out by a person using a
paper and pencil in a minimum number of times.
4. Terminate: After some minimum number operation algorithm must come to an end.
5. Output: An algorithm is written to solve the problem; therefore it must produce one or more
computed result or answer called output.

What is a Flowchart?

Flowchart is a graphical representation of an algorithm. Programmers often use it as a program-


planning tool to solve a problem. It makes use of symbols which are connected among them to
indicate the flow of information and processing.
The process of drawing a flowchart for an algorithm is known as “flowcharting”.
Basic Symbols used in Flowchart Designs

1. Terminal: The oval symbol indicates Start, Stop and Halt in a program’s logic
flow. A pause/halt is generally used in a program logic under some error conditions.
Terminal is the first and last symbols in the flowchart.

• Input/Output: A parallelogram denotes any function of input/output type. Program


instructions that take input from input devices and display output on output devices
are indicated with parallelogram in a flowchart.

• Processing: A box represents arithmetic instructions. All arithmetic processes such


as adding, subtracting, multiplication and division are indicated by action or process
symbol.

• Decision Diamond symbol represents a decision point. Decision based operations


such as yes/no question or true/false are indicated by diamond in flowchart.

• Connectors: Whenever flowchart becomes complex or it spreads over more than


one page, it is useful to use connectors to avoid any confusions. It is represented by
a circle.

• Flow lines: Flow lines indicate the exact sequence in which instructions are
executed. Arrows represent the direction of flow of control and relationship among
different symbols of flowchart.
Rules For Creating Flowchart:

A flowchart is a graphical representation of an algorithm.it should follow some rules while


creating a flowchart
Rule 1: Flowchart opening statement must be ‘start’ keyword.
Rule 2: Flowchart ending statement must be ‘end’ keyword.
Rule 3: All symbols in the flowchart must be connected with an arrow line.
Rule 4: The decision symbol in the flowchart is associated with the arrow line.

Advantages of Flowchart:
• Flowcharts are a better way of communicating the logic of the system.
• Flowcharts act as a guide for blueprint during program designed.
• Flowcharts help in debugging process.
• With the help of flowcharts programs can be easily analyzed.
• It provides better documentation.
• Flowcharts serve as a good proper documentation.
• Easy to trace errors in the software.
• Easy to understand.
• The flowchart can be reused for inconvenience in the future.
• It helps to provide correct logic.

Disadvantages of Flowchart:
• It is difficult to draw flowcharts for large and complex programs.
• There is no standard to determine the amount of detail.
• Difficult to reproduce the flowcharts.
• It is very difficult to modify the Flowchart.
• Making a flowchart is costly.
• Some developer thinks that it is waste of time.
• It makes software processes low.
• If changes are done in software, then the flowchart must be redrawn

What Is Pseudo-Code in C?
In C programming language, it becomes mandatory to follow syntax while executing the program,
and it becomes challenging to understand the logic of the complex program. Therefore, to
understand the program logic in a better way and to solve the complex problem, you must write it
in pseudocode, which is written in simple English that makes it easy to understand.
The pseudocode in C is an informal way of writing a program for better human understanding. It
is written in simple English, making the complex program easier to understand.
Pseudocode cannot be compiled or interpreted. It doesn't follow the programming language's
syntax; it is thus written in pseudocode so that any programmers or non-programmers can easily
understand it.
pseudo-code for Factorial Program

Start program

Declare fact and n


Enter number for n

for i=1 to i <=n

Perform fact = fact * i

Display fact

End program

Type of Programming Languages

1. Procedural programming languages

A procedural language follows a sequence of statements or commands in order to achieve a desired


output. Each series of steps is called a procedure, and a program written in one of these languages
will have one or more procedures within it. Common examples of procedural languages include:
• C and C++
• Java
• Pascal
• BASIC

2. Functional programming languages

Rather than focusing on the execution of statements, functional languages focus on the output of
mathematical functions and evaluations. Each function–a reusable module of code–performs a
specific task and returns a result. The result will vary depending on what data you input into the
function. Some popular functional programming languages include:
• Scala
• Erlang
• Haskell
• Elixir
• F#

3. Object-oriented programming languages

This type of language treats a program as a group of objects composed of data and program
elements, known as attributes and methods. Objects can be reused within a program or in other
programs. This makes it a popular language type for complex programs, as code is easier to reuse
and scale. Some common object-oriented programming (OOP) languages include:
• Java
• Python
• PHP
• C++
• Ruby
4. Scripting languages

Programmers use scripting languages to automate repetitive tasks, manage dynamic web content,
or support processes in larger applications. Some common scripting languages include:
• PHP
• Ruby
• Python
• bash
• Perl
• Node.js

5. Logic programming languages

Instead of telling a computer what to do, a logic programming language expresses a series of facts
and rules to instruct the computer on how to make decisions. Some examples of logic languages
include:
• Prolog
• Absys
• Datalog
• Alma-0

Generation of Programming Language

1. First-Generation Language :
The first-generation languages are also called machine languages/ 1G language. This language
is machine-dependent. The machine language statements are written in binary code (0/1 form)
because the computer can understand only binary language.
Advantages :
1. Fast & efficient as statements are directly written in binary language.
2. No translator is required.
Disadvantages :
1. Difficult to learn binary codes.
2. Difficult to understand – both programs & where the error occurred.
2. Second Generation Language :
The second-generation languages are also called assembler languages/ 2G languages. Assembly
language contains human-readable notations that can be further converted to machine language
using an assembler.
Assembler – converts assembly level instructions to machine-level instructions.
Programmers can write the code using symbolic instruction codes that are meaningful
abbreviations of mnemonics. It is also known as low-level language.
Advantages :
1. It is easier to understand if compared to machine language.
2. Modifications are easy.
3. Correction & location of errors are easy.
Disadvantages :
1. Assembler is required.
2. This language is architecture /machine-dependent, with a different instruction set for different
machines.
3. Third-Generation Language :
The third generation is also called procedural language /3 GL. It consists of the use of a series
of English-like words that humans can understand easily, to write instructions. It’s also called
High-Level Programming Language. For execution, a program in this language needs to be
translated into machine language using a Compiler/ Interpreter. Examples of this type of
language are C, PASCAL, FORTRAN, COBOL, etc.
Advantages :
1. Use of English-like words makes it a human-understandable language.
2. Lesser number of lines of code as compared to the above 2 languages.
3. Same code can be copied to another machine & executed on that machine by using compiler-
specific to that machine.
Disadvantages :
1. Compiler/ interpreter is needed.
2. Different compilers are needed for different machines.
4. Fourth Generation Language :
The fourth-generation language is also called a non – procedural language/ 4GL. It enables users
to access the database. Examples: SQL, Foxpro, Focus, etc.
These languages are also human-friendly to understand.
Advantages :
1. Easy to understand & learn.
2. Less time is required for application creation.
3. It is less prone to errors.
Disadvantages :
1. Memory consumption is high.
2. Has poor control over Hardware.
3. Less flexible.
5. Fifth Generation Language :
The fifth-generation languages are also called 5GL. It is based on the concept of artificial
intelligence. It uses the concept that rather than solving a problem algorithmically, an
application can be built to solve it based on some constraints, i.e., we make computers learn to
solve any problem. Parallel Processing & superconductors are used for this type of language to
make real artificial intelligence.
Examples: PROLOG, LISP, etc.
Advantages :
1. Machines can make decisions.
2. Programmer effort reduces to solve a problem.
3. Easier than 3GL or 4GL to learn and use.
Disadvantages :
1. Complex and long code.
2. More resources are required & they are expensive too.

You might also like