0% found this document useful (0 votes)
276 views

PPS Unit 1 First Half Notes

This document provides an overview of computer components and classifications. It discusses that a computer accepts data as input, processes it, produces output, and stores information. The main components are the hardware (physical elements like the CPU, memory, storage, and input/output devices) and software (programs and operating systems). Computers are classified based on their size and power, from personal computers for individual use up to mainframes that can support thousands of users. Laptops, tablets, and smartphones are mobile computer devices.

Uploaded by

Neha Reddy
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)
276 views

PPS Unit 1 First Half Notes

This document provides an overview of computer components and classifications. It discusses that a computer accepts data as input, processes it, produces output, and stores information. The main components are the hardware (physical elements like the CPU, memory, storage, and input/output devices) and software (programs and operating systems). Computers are classified based on their size and power, from personal computers for individual use up to mainframes that can support thousands of users. Laptops, tablets, and smartphones are mobile computer devices.

Uploaded by

Neha Reddy
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/ 42

Programming For Problem Solving (PPS)

Unit 1
 Introduction to Computers
 Computer
A computer is an electronic device, operating under the control of
instructions stored in its own memory that can accept data (input),
process the data according to specified rules, produce information
(output), and store the information for future use.
 Functionalities of a computer:
Any digital computer carries out five functions in gross terms:

 Computer Components
Any kind of computers consists of HARDWARE AND SOFTWARE.

Hardware:
Computer hardware is the collection of physical elements that constitutes
a computer system. Computer hardware refers to the physical parts or
components of a computer such as the monitor, mouse, keyboard,
computer data storage, hard drive disk (HDD), system unit (graphic cards,
sound cards, memory, motherboard and chips), etc. all of which are
physical objects that can be touched.
Input Devices
Input device is any peripheral (piece of computer hardware equipment to
provide data and control signals to an information processing system such
as a computer or other information appliance.
Input device Translate data from form that humans understand to one that
the computer can work with. Most common are keyboard and mouse
Central Processing Unit (CPU)
A CPU is brain of a computer. It is responsible for all functions and
processes. Regarding computing power, the CPU is the most important
element of a computer system.
The CPU is comprised of three main parts :
* Arithmetic Logic Unit (ALU): Executes all arithmetic and logical
operations. Arithmetic calculations like as addition, subtraction,
multiplication and division. Logical operation like compare numbers,
letters, or special characters.
* Control Unit (CU): controls and co-ordinates computer components.
1. Read the code for the next instruction to be executed.
2. Increment the program counter so it points to the next instruction.
3. Read whatever data the instruction requires from cells in memory.
4. Provide the necessary data to an ALU or register.
5. If the instruction requires an ALU or specialized hardware to complete,
instruct the hardware to perform the requested operation.
* Registers :Stores the data that is to be executed next, "very fast storage
area".
Primary Memory:-
1. RAM: Random Access Memory (RAM) is a memory scheme within
the computer system responsible for storing data on a temporary basis, so
that it can be promptly accessed by the processor as and when needed. It
is volatile in nature, which means that data will be erased once supply to
the storage device is turned off. RAM stores data randomly and the
processor accesses these data randomly from the RAM storage. RAM is
considered "random access" because you can access any memory
cell directly if you know the row and column that intersect at that cell.
2. ROM (Read Only Memory): ROM is a permanent form of storage.
ROM stays active regardless of whether power supply to it is turned on or
off. ROM devices do not allow data stored on them to be modified.
Secondary Memory:-
Stores data and programs permanently :its retained after the power is
turned off
1. Hard drive (HD): A hard disk is part of a unit, often called a "disk drive," "hard
drive," or "hard disk drive," that store and provides relatively quick access to
large amounts of data on an electromagnetically charged surface or set of
surfaces.
2. Optical Disk: an optical disc drive (ODD) is a disk drive that uses laser light
as part of the process of reading or writing data to or from optical discs. Some
drives can only read from discs, but recent drives are commonly both readers
and recorders, also called burners or writers. Compact discs, DVDs, and
Blu-ray discs are common types of optical media which can be read and
recorded by such drives. Optical drive is the generic name; drives are usually
described as "CD" "DVD", or "Bluray", followed by "drive", "writer", etc. There
are three main types of optical media: CD, DVD, and Blu-ray disc. CDs can
store up to 700 megabytes (MB) of data and DVDs can store up to 8.4 GB of
data. Blu-ray discs, which are the newest type of optical media, can store up to
50 GB of data. This storage capacity is a clear advantage over the floppy disk
storage media (a magnetic media), which only has a capacity of 1.44 MB.
3. Flash Disk
A storage module made of flash memory chips. A Flash disks have no
mechanical platters or access arms, but the term "disk" is used because the
data are accessed as if they were on a hard drive. The disk storage structure is
emulated.

Output devices
An output device is any piece of computer hardware equipment used to
communicate the results of data processing carried out by an information
processing system (such as a computer) which converts the electronically
generated information into human readable form.
Software
Software is a generic term for organized collections of computer data and
instructions, often broken into two major categories: system software that
provides the basic non task-specific functions of the computer, and
application software which is used by users to accomplish specific tasks.
Software Types
A. System software is responsible for controlling, integrating, and
managing the individual hardware components of a computer system so
that other software and the users of the system see it as a functional unit
without having to be concerned with the low-level details such as
transferring data from memory to disk, or rendering text onto a display.
Generally, system software consists of an operating system and some
fundamental utilities such as disk for matters, file managers,display
managers, text editors, user authentication (login) and management tools,
and networking and device control software.
B. Application software is used to accomplish specific tasks other than
just running the computer system. Application software may consist of a
single program, such as an image viewer; a small collection of programs
(often called a software package) that work closely together to
accomplish a task, such as a spreadsheet or text processing system; a
larger collection (often called a software suite) of related but independent
programs and packages that have a common user interface or shared data
format, such as Microsoft Office, which consists of closely integrated
word processor, spreadsheet, database, etc.; or a software system, such as
a database management system, which is a collection of fundamental
programs that may provide some service to a variety of other independent
applications.
Unit of Measurements
Storage measurements: The basic unit used in computer data storage is
called a bit (binary digit). Computers use these little bits, which are
composed of ones and zeros, to do things and talk to other computers. All
your files, for instance, are kept in the computer as binary files and
translated into words and pictures by the software (which is also ones and
zeros). This two number system, is called a “binary number system” since
it has only two numbers in it. The decimal number system in contrast has
ten unique digits, zero through nine.

Size example
• 1 bit - answer to an yes/no question
• 1 byte - a number from 0 to 255.
• 90 bytes: enough to store a typical line of text from a book.
• 4 KB: about one page of text.
• 120 KB: the text of a typical pocket book.
• 3 MB - a three minute song (128k bitrate)
• 650-900 MB - an CD-ROM
• 1 GB -114 minutes of uncompressed CD-quality audio at 1.4 Mbit/s
• 8-16 GB - size of a normal flash drive
Speed measurement: The speed of Central Processing Unit (CPU) is
measured by Hertz (Hz), Which represent a CPU cycle. The speed of
CPU is known as Computer Speed.
 Computers classification***
Computers can be generally classified by size and power as follows,
though there is Considerable overlap:
• Personal computer: A small, single-user computer based on a
microprocessor. In addition to the microprocessor, a personal computer
has a keyboard for entering data, a monitor for displaying information,
and a storage device for saving data.
• workstation : A powerful, single-user computer. A workstation is like a
personal computer, but it has a more powerful microprocessor and a
higher-quality monitor.
• minicomputer : A multi-user computer capable of supporting from 10 to
hundreds of users simultaneously.
• mainframe : A powerful multi-user computer capable of supporting
many hundreds or thousands of users simultaneously.
• supercomputer : An extremely fast computer that can perform hundreds
of millions of instructions per second.

Laptop and Smart phone Computers


LAPTOP: A laptop is a battery or AC-powered personal computer that
can be easily carried and used in a variety of locations. Many laptops are
designed to have all of the functionality of a desktop computer, which
means they can generally run the same software and open the same types
of files. However, some laptops, such as net books, sacrifice some
functionality in order to be even more portable.
Netbook: A netbook is a type of laptop that is designed to be even more
portable. Netbooks are often cheaper than laptops or desktops. They are
generally less powerful than other types of computers, but they provide
enough power for email and internet access, which is where the name
"netbook" comes from.
Mobile Device: A mobile device is basically any handheld computer. It is
designed to be extremely portable, often fitting in the palm of your hand
or in your pocket. Some mobile devices are more powerful, and they
allow you to do many of
the same things you can do with a desktop or laptop computer. These
include
tablet computers, e-readers, and smartphones.
Tablet Computers: Like laptops, tablet computers are designed to be
portable. However, they provide a very different computing experience.
The most obvious difference is that tablet computers don't have
keyboards or touchpads. Instead, the entire screen is touch-sensitive,
allowing you to type on a virtual keyboard and use your finger as a mouse
pointer. Tablet computers are mostly designed for consuming media, and
they are optimized for tasks like web browsing, watching videos, reading
e-books, and playing games. For many people, a "regular" computer like
a desktop or laptop is still needed in order to use some programs.
However, the convenience of a tablet computer means that it may be ideal
as a second computer.
Smartphones: A smartphone is a powerful mobile phone that is designed
to run a variety of applications in addition to phone service. They are
basically small tablet computers, and they can be used for web browsing,
watching videos, reading e-books, playing games and more.
 Data, Information and Knowledge
Data: Facts and figures which relay something specific, but which are not
organized in any way and which provide no further information regarding
patterns, context, etc. So data means "unstructured facts and figures that
have the least impact on the typical manager."
Information: For data to become information, it must be contextualized,
categorized, calculated and condensed. Information thus paints a bigger
picture; it is data with relevance and purpose. It may convey a trend in the
environment, or perhaps indicate a pattern of sales for a given period of
time. Essentially information is found "in answers to questions that begin
with such words as who, what, where, when, and how many".
Knowledge: Knowledge is closely linked to doing and implies know-how
and understanding. The knowledge possessed by each individual is a
product of his experience, and encompasses the norms by which he
evaluates new inputs from his surroundings.
The content of the human mind can be classified into four categories:
1. Data: symbols
2. Information: data that are processed to be useful; provides answers to
"who", "what",
"where", and "when" questions
3. Knowledge: application of data and information; answers "how"
questions
4. Wisdom: evaluated understanding.
We need to understand that processing data produced Information and
process
Information produces Knowledge and so on
 Characteristics of Computer
Speed, accuracy, diligence, storage capability and versatility are some of
the key characteristics of a computer. A brief overview of these
characteristics are
• Speed: The computer can process data very fast, at the rate of millions
of instructions per second. Some calculations that would have taken hours
and days to complete otherwise, can be completed in a few seconds using
the computer. For example, calculation and generation of salary slips of
thousands of employees of an organization, weather forecasting that
requires analysis of a large amount of data related to temperature,
pressure and humidity of various places, etc.
• Accuracy: Computer provides a high degree of accuracy. For example,
the computer can accurately give the result of division of any two
numbers up to 10 decimal places.
• Diligence: When used for a longer period of time, the computer does
not get tired or fatigued. It can perform long and complex calculations
with the same speed and accuracy from the start till the end.
• Storage Capability: Large volumes of data and information can be
stored in the computer and also retrieved whenever required. A limited
amount of data can be stored, temporarily, in the primary memory.
Secondary storage devices like floppy disk and compact disk can store a
large amount of data permanently.
• Versatility: Computer is versatile in nature. It can perform different
types of tasks with the same ease. At one moment you can use the
computer to prepare a letter document and in the next moment you may
play music or print a document. Computers have several limitations too.
Computer can only perform tasks that it has been programmed to do.
Computer cannot do any work without instructions from the user. It
executes
instructions as specified by the user and does not take its own decisions.
 Computer Viruses*
Viruses: A virus is a small piece of software that piggybacks on real
programs. For example, a virus might attach itself to a program such as a
spreadsheet program. Each time the spreadsheet program runs, the virus
runs, too, and it has the chance to reproduce (by attaching to other
programs) or wreak havoc.
•E-mail viruses: An e-mail virus travels as an attachment to e-mail
messages, and usually replicates itself by automatically mailing itself to
dozens of people in the victim's e-mail address book. Some e-mail viruses
don't even require a double-click -- they launch when you view the
infected message in the preview pane of your e-mail software [source:
Johnson].
•Trojan horses: A Trojan horse is simply a computer program. The
program claims to do one thing (it may claim to be a game) but instead
does damage when you run it (it may erase your hard disk). Trojan horses
have no way to replicate automatically.
•Worms: A worm is a small piece of software that uses computer
networks and security holes to replicate itself. A copy of the worm scans
the network for another machine that has a specific security hole. It
copies itself to the new machine using the security hole, and then starts
replicating from there, as well.
What are some tips to avoid viruses and lessen their impact?*
Install anti-virus software from a reputable vendor. Update it and use it
regularly.
In addition to scanning for viruses on a regular basis, install an "on
access" scanner (included in most anti-virus software packages) and
configure it to start each time you start up your computer. This will
protect your system by checking for viruses each time you run an
executable file.
Use a virus scan before you open any new programs or files that may
contain executable code. This includes packaged software that you buy
from the store as well as any program you might download from the
Internet.
If you are a member of an online community or chat room, be very
careful about accepting files or clicking links that you find or that people
send you within the community.
Make sure you back up your data (documents, bookmark files, important
email messages, etc.) on disc so that in the event of a virus infection, you
do not lose valuable work.
 COMPUTER ENVIRONMENT
A computer system uses many devices, arranged in different ways to solve
many problems. This constitutes a computing environment where many
computers are used to process and exchange information to handle multiple
issues.
The different types of Computing Environments are −

Personal Computing Environment


In the personal computing environment, there is a single computer system. All
the system processes are available on the computer and executed there. The
different devices that constitute a personal computing environment are laptops,
mobiles, printers, computer systems, scanners etc
Time Sharing Computing Environment
The time sharing computing environment allows multiple users to share the
system simultaneously. Each user is provided a time slice and the processor
switches rapidly among the users according to it. Because of this, each user
believes that they are the only ones using the system.
Client Server Computing Environment
In client server computing, the client requests a resource and the server
provides that resource. A server may serve multiple clients at the same time
while a client is in contact with only one server. Both the client and server
usually communicate via a computer network but sometimes they may reside
in the same system.
Distributed Computing Environment
A distributed computing environment contains multiple nodes that are
physically separate but linked together using the network. All the nodes in this
system communicate with each other and handle processes in tandem. Each
of these nodes contains a small part of the distributed operating system
software.
Cloud Computing Environment
The computing is moved away from individual computer systems to a cloud of
computers in cloud computing environment. The cloud users only see the
service being provided and not the internal details of how the service is
provided. This is done by pooling all the computer resources and then
managing them using a software.
Cluster Computing Environment
The clustered computing environment is similar to parallel computing
environment as they both have multiple CPU’s. However a major difference is
that clustered systems are created by two or more individual computer
systems merged together which then work parallel to each other.
 Computer Languages:
Programming languages for computers are developed with the primary
objective of facilitating a large number of persons to use computers without the
need to know in detail the internal structure of a computer. Languages are
matched to the type of applications which are to be programmed using the
language. The ideal language would be one which expresses precisely the
specification of a problem to be solved, and converts it into a series of
instructions for a computer. It is not possible to achieve this ideal as a clear
specification of a problem is often not available and developing an algorithm
from specifications requires subject knowledge and expertise. In actual
practice, a detailed algorithm to solve a problem is the starting point and it is
expressed as a program in a programming language. A large number of
languages, over a thousand, exist each catering to a different class of
applications. All modern programming languages (with one exception) are
designed to be machine independent. In other words, the structure of the
programming language would not depend upon the internal structure of a
specified computer; one should be able to execute a program written in the
programming language on any computer regardless of who manufactured it or
what model it is. Such languages are known as high level machine
independent programming languages.
We will also point out some of the recent developments in programming
languages.
Assembly Language :
The first step in the evolution of programming languages was the
development of what is known as an assembly language. In an assembly
language, mnemonics are used to represent operations to be performed by the
computer and strings of characters to represent addresses of locations in the
computer’s memory where the operands will be stored. Thus the language is
matched to a particular computer’s processor structure and is thus machine
dependent. A translator called an assembler translates a program written in
assembly language to a set of machine instructions, which can be executed by
a computer. Now-a-days programs are written in assembly language only in
applications which are cost sensitive or time critical as efficiency of machine
code is of paramount importance in these types of applications. A cost
sensitive application is one in which microprocessors are used to enhance the
functionality of consumer items such as washing machines or music systems.
In these cases the program is stored in a read only memory and its size is
small. Thus code optimization is important. A time-critical application is use of
microprocessors in aircraft controls where real time operation of the system is
required. Here again the number of machine instructions executed should be
minimized.
High Level Languages :
During the evolution of computers, till about 1955, computers were slow and
had a small memory. Thus programming efficiency was very important and
assembly language was dominant. With improvements in technology,
computers were designed with larger memory capacity, higher speed and
improved reliability. The tremendous potential of computer applications in
diverse areas was foreseen. It was evident that this potential could be realized
only if a non-expert user could effectively use the computer to solve problems.
It was thus clear that a user should be concerned primarily with the
development of appropriate algorithms to solve problems and not with the
internal logical structure of a computer. Consequently a good notation to
express algorithms became an essential requirement. For algorithms to be
executed by computers, the notation to express them should be simple,
concise, precise and unambiguous. The notation should also match the type of
algorithm. For example, programming languages to solve science and
engineering problems should support arithmetic using wide ranging, high
precision real and complex numbers and should have features to express
operations with arrays and matrices. On the other hand, algorithms for
processing business data would have operations to be performed on massive
amounts of organized data known as files. The notation, in this case, must
facilitate describing files and formatting and printing intricate reports. Such
notations to express algorithms are known as high level, machine independent,
programming languages. High level programming languages are further
classified as procedural and non-procedural. Languages which express
step-by-step algorithms written to solve a problem are known as procedural
languages whereas those which express specifications of a program to be
solved are known as non procedural.
Procedural Languages:
Procedural languages have facilities to: i) specify data elements such as real,
integer, boolean, characters and data structures such as arrays, matrices,
stacks, records, sets, strings of characters, lists, trees, etc., ii) control
structures to sequence operations to be performed. An if then else structure is
necessary to allow programs to follow different sequences of statements
based on testing a condition. For example, the following statement:
Associated with each high level language is an elaborate computer program
which translates it into the machine language of the computer in which it is to
be executed. There are two types of translators. One of them takes each
statement of the high level language, translates it and immediately executes it.
This is called an interpreter. Interpreters are easy to write but the translated
programs’ execution is slow. The other approach is to scan the whole program
and translate it into an equivalent machine language program. Such a
translator is called a compiler. A compiler is a complex program but the
compiled machine code takes lesser time to execute compared to an
interpreted program.
A Classification of Programming Languages:
We have classified high level machine independent languages into three
groups, namely, procedural, non-procedural and problem-oriented. Procedural
languages have as their starting

point an algorithm to solve the problem. Languages such as FORTRAN,


COBOL and C are purely algorithmic. These languages provide a
methodology to break up a large job into a number of tasks and programming
the tasks independently as functions or subroutines. These functions or
subroutines are then combined to form a program. The general idea is to
simplify debugging a program and to reuse the procedures in other programs
which may need them. Over the years it was realised that this was not
sufficient to enable re-use of programs. Subroutines and functions are too rigid.
They require the specification of the type of data to be used a priori and the
data to be passed to them in a pre-specific order. As the cost of programming
continually increased it was realised that ‘building’ programs using a library of
reusable ‘components’ was imperative. This led to the emergence of the
so-called object-oriented languages. In these languages the concept of
subroutine/functions is extended to that of an object. An object models a
complex real world or an abstract object. A real world object, for example, is a
student whereas an abstract object is a course taken by a student. In an object
oriented (OOP) program an object is modelled by a collection of data
structures and a set of procedures that can be performed on this data structure.
A program consists of a collection of objects, each object providing a service
when it is invoked and all the objects co-operating to get the job done. Objects
are invoked by sending messages to them and objects return messages when
the job is done. The action performed in response to a message can vary
depending on the data and type of parameters. This is called polymorphism.
Objects form class hierarchy with super class (parent) and subclass (child)
relationship. An object can use procedures and data defined on objects in its
super class through inheritance. The advantages of object oriented
programming (OOP) accrue only when a large software project is undertaken
– also known as ‘programming in the large’. The methodology of OOP enables
a programmer to remain close to the conceptual higher level model of the real
world problem. One of the earliest OOP languages to be developed was Small
talk. It, however, did not become popular. Currently an object oriented version
of C known as C++ is the most popular OOP language.
Another development, which has taken place in the last few years, is the
internet – an international network of a very large number of national computer
networks. The technology developed in creating the internet has been adapted
for networking computers within an organization. A computer network within an
organization using protocols and providing services similar to an internet is
called an intranet. In both inter and intranet small application programs (agents
or objects to perform some services – known as applets) may be developed at
any one of the computers connected to the network. One would like to create a
new application by using these applets by either importing them to one’s own
computer or using them via the network. A language known as JAVA, which is
an object oriented language achieves this. This language achieves machine
independence by defining a JAVA virtual machine for which the compiler is
written. The JAVA code compiled for the virtual machine is then executed on
any machine by an interpreter which generates machine code from the
compiled code. This technique makes it easy to port JAVA language to any
machine quickly (see Figure 2). JAVA is getting wide acceptance now as

a programming language to write applications for a network of heterogeneous


computers.
Scripting Languages:
Programming languages such as C and JAVA are also known as system
programming languages as they have been used to develop large systems.
For example C has been used to write the Unix operating system. System
programming languages are strongly typed, that is, each variable must be
declared as a particular type – real, integer, pointer etc. Typing is used both for
easy readability and enabling more efficient compilation and error detection.
Another class of languages, which are gaining wider acceptance is called
scripting language [3]. Scripting languages assume that a collection of useful
programs, each performing a task, already exists in other languages. It has
facilities to combine these components to perform a complex task. A scripting
language may be thus thought of as a gluing language, which glues together
components. One of the earliest scripting languages is Unix Shell. Unix shell
filter programs, read a stream of bytes from an input and write a stream of
bytes on to an output. Any two programs can be connected by attaching the
output of one program to the input of the other. The following shell commands
stack three filters to count the number of lines in the selection that contains the
word ‘language’.
The program select reads the given text that is currently on the display and
prints the text on its output; the grep program reads its input and prints as its
output the lines containing the word ‘language’; the wc program counts the
number of lines on its input. Each of these programs select, grep and wc are
independent programs which could be combined with other programs also in
many ways. Another popular scripting language is Visual Basic, which is used
to develop Graphical User Interfaces (GUI) on the screen of a Visual Display
Unit. It is expected that with increasing complexity of applications it will be
more cost effective

to glue together existing ‘program components’ using scripting languages. In


Above Table we give a comparison of some of the languages.
Non-procedural Languages:
In procedural languages (also known as imperative languages) each
statement causes the values stored in one or more memory locations to
change. Program design consists of writing a sequence of statements, which
transform the ‘state’ of the memory from an initial state to a final state which is
the solution to the problem. Non-procedural functional languages solve a
problem by applying a set of functions to the initial variables in specific ways to
get the answer. The syntax of such languages is similar to

where f’s are the successive function applications which transform their
arguments which, at the start, is the initial data. LISP and ML are two
languages in use which support this model. LISP has been widely used to
program artificial intelligence applications. Another non-procedural class of
languages is called rule based languages or logic programming languages. A
logic program is expressed as a set of atomic sentences (known as facts) and
Horn clauses (if then rules). A query is then posed. Execution of the program
now begins and the system tries to find out if the answer to the query is true or
false for the given facts and rules. PROLOG is the best known language of this
type.
Problem Oriented Languages:
Problem oriented languages are designed to solve a narrow class of problems.
A user of such a language need not express in detail the procedure used to
solve a problem. Ready made procedures are pre- programmed. The user
merely presents the data in a flexible ‘language’. MATLAB is a very popular
language among scientists and engineers to solve a wide class of problems in
digital signal processing, control systems, modelling systems described by
differential equations, matrix computations etc. Another class of problem
oriented languages is for symbolic manipulation, for example, simplifying a
complex algebraic expression or getting the indefinite integral of a complex
expression. MATHEMATICA is a popular language of this type.
Classification Based on Applications:
Another method of classifying computer languages is by applications. The
major applications of computers are in the following areas: i. Business Data
Processing where large files are to be processed. COBOL has been the
dominant language in this area. We have seen, however, the emergence of
spreadsheet based ‘languages’ for answering ‘what if’ type questions.
Languages known as 4GLs (Fourth Generation Languages) are also used
which provide query languages to access data from data bases and
manipulate them. 4 GLs also have special features like ‘fill in the blanks’ to
obtain answers to queries and for designing good looking forms. ii. Scientific
applications require numeric intensive computing such as those used to solve
problems in science and engineering. Fortran 90 is the dominant language in
this area. C is making inroads. Recently Fortran 95 standard has been
published which incorporates features to write Fortran programs for parallel
computers.

 Creating and running programs:


Creating and Running C Program
Generally, the programs created using programming languages like C, C++,
Java, etc., are written using a high-level language like English. But, the
computer cannot understand the high-level language. It can understand only
low-level language. So, the program written in the high-level language needs
to be converted into the low-level language to make it understandable for the
computer. This conversion is performed using either Interpreter or Compiler.
Popular programming languages like C, C++, Java, etc., use the compiler to
convert high-level language instructions into low-level language instructions. A
compiler is a program that converts high-level language instructions into
low-level language instructions. Generally, the compiler performs two things,
first it verifies the program errors, if errors are found, it returns a list of errors
otherwise it converts the complete code into the low-level language.
To create and execute C programs in the Windows Operating System, we
need to install Turbo C software. We use the following steps to create and
execute C programs in Windows OS…

Step 1: Creating a Source Code


Source code is a file with C programming instructions in a high-level language.
To create source code, we use any text editor to write the program instructions.
The instructions written in the source code must follow the C programming
language rules. The following steps are used to create a source code file in
Windows OS…

 Click on the Start button


 Select Run
 Type cmd and press Enter
 Type cd c:\TC\bin in the command prompt and press Enter
 Type TC press Enter
 Click on File -> New in C Editor window
 Type the program
 Save it as FileName.c (Use shortcut key F2 to save)

Step 2: Compile Source Code (Alt + F9)


The compilation is the process of converting high-level language instructions
into low-level language instructions. We use the shortcut key Alt + F9 to
compile a C program in Turbo C.
The compilation is the process of converting high-level language
instructions into low-level language instructions.
Whenever we press Alt + F9, the source file is going to be submitted to the
Compiler. On receiving a source file, the compiler first checks for the Errors. If
there are any Errors then compiler returns List of Errors, if there are no errors
then the source code is converted into object code and stores it as a file
with .obj extension. Then the object code is given to the Linker. The Linker
combines both the object code and specified header file code and generates
an Executable file with a .exe extension.
Step 3: Executing / Running Executable File (Ctrl + F9)
After completing compilation successfully, an executable file is created with
a .exe extension. The processor can understand this .exe file content so that it
can perform the task specified in the source file.
We use a shortcut key Ctrl + F9 to run a C program. Whenever we press
Ctrl + F9, the .exe file is submitted to the CPU. On
receiving .exe file, CPU performs the task according to the instruction written
in the file. The result generated from the execution is placed in a window
called User Screen.
Step 4: Check Result (Alt + F5)
After running the program, the result is placed into User Screen. Just we need
to open the User Screen to check the result of the program execution. We use
the shortcut key Alt + F5 to open the User Screen and check the result.

Execution Process of a C Program


When we execute a C program it undergoes with the following process…

The file which contains c program instructions in a high-level language is said


to be source code. Every c program source file is saved with .c extension, for
example, Sample.c.
Whenever we press Alt + F9 the source file is submitted to the compiler.
Compiler checks for the errors, if there are any errors, it returns a list of errors,
otherwise generates object code in a file with name Sample.obj and submit it
to the linker. The linker combines the code from specified header file into an
object file and generates executable file as Sample.exe. With this compilation
process completes.
Now, we need to run the executable file (Sample.exe). To run a program we
press Ctrl + F9. When we press Ctrl + F9 the executable file is submitted to the
CPU. Then CPU performs the task according to the instructions written in that
program and place the result into UserScreen.
Then we press Alt + F5 to open UserScreen and check the result of the
program.
Important Points

 C program file (Source file) must save with .c extension.


 The compiler converts complete program at a time from high-level
language to low-level language.
 Input to the compiler is .c file and output from the compiler is .exe file,
but it also generates .obj file in this process.
 The compiler converts the file only if there are no errors in the source
code.
 CPU places the result in User Screen window.

Creating and Running C Programs:

The steps for creating and running programs are: writing/editing, compiling,
linking and execution. This can be viewed diagrammatically as shown below:
Writing/Editing: The first step in creating programs is, writing or editing the
program. A program can be written in any text editor like notepad. After writing
a program, the program must be saved, In C language, the program is saved
with the extension “.c”. This is the source program written in a high-level
language.

Compilation: After writing and saving the source program, the next step is
compilation. Here we will use a software called as compiler, which converts a
program written in high-level language into machine language. The resultant
file is known as an object file in C. The extension of that file is “.obj”.
Linking: After compilation the next step is linking. Here software called linker
is used. The linker links the program with external library files which contains
the code for predefined functions and creates an executable file. The
extension of the executable file is “.exe”.

Execution: Finally after the executable file is created after linking, the next
step is execution. The operating system executes the executable file which is
the machine code with the help of the CPU and other hardware components.

 Software Development Method:


Program Development Life Cycle
When we want to develop a program using any programming language, we
follow a sequence of steps. These steps are called phases in program
development. The program development life cycle is a set of steps or phases
that are used to develop a program in any programming language.
Generally, the program development life cycle contains 6 phases, they are as
follows….

 Problem Definition
 Problem Analysis
 Algorithm Development
 Coding & Documentation
 Testing & Debugging
 Maintenance
1. Problem Definition
In this phase, we define the problem statement and we decide the boundaries
of the problem. In this phase we need to understand the problem statement,
what is our requirement, what should be the output of the problem solution.
These are defined in this first phase of the program development life cycle.

2. Problem Analysis
In phase 2, we determine the requirements like variables, functions, etc. to
solve the problem. That means we gather the required resources to solve the
problem defined in the problem definition phase. We also determine the
bounds of the solution.

3. Algorithm Development
During this phase, we develop a step by step procedure to solve the problem
using the specification given in the previous phase. This phase is very
important for program development. That means we write the solution in step
by step statements.

4. Coding & Documentation


This phase uses a programming language to write or implement the actual
programming instructions for the steps defined in the previous phase. In this
phase, we construct the actual program. That means we write the program to
solve the given problem using programming languages like C, C++, Java, etc.,
5. Testing & Debugging
During this phase, we check whether the code written in the previous step is
solving the specified problem or not. That means we test the program whether
it is solving the problem for various input data values or not. We also test
whether it is providing the desired output or not.

6. Maintenance
During this phase, the program is actively used by the users. If any
enhancements found in this phase, all the phases are to be repeated to make
the enhancements. That means in this phase, the solution (program) is used
by the end-user. If the user encounters any problem or wants any
enhancement, then we need to repeat all the phases from the starting, so that
the encountered problem is solved or enhancement is added.

 Software Development Process

Let’s take a look at the big picture of the software development process.
Computer programming is a cycle of designing, creating and supporting a
software. These are usually divided into the following sub-tasks:
 Defining the task

It’s a common knowledge that a well defined task is half of the solution.
When you start a project you must know what exactly the customer expects.
The more detailed the description of the task - the better. Ideally, before the
start of the project you will have a blueprint( a plan) containing the design and
function of every page, form, button etc.

 Choose the hardware and software needed

For some tasks (usually in embedded programming) a special hardware is


required. For instance, if you want to write a program for a PIC microcontroller
you will need a PIC chip, a device to write the program in the chip (pic
programmer) and software to command the programmer.
 Choose the correct algorithms

Using the right algorithms is crucial. Professional programming is all about


creating flawlessly working programs. Later we will discuss the inevitable
choice between optimal usage of CPU time and memory. This is one of the
most important phases of the software development process.

 Coding

Finally it is time to write our program in the chosen computer language. Yes,
this is the step, where we actually create the program.

 Debug

One more phase of the software development process. Once we created


some code it is time to see if it is doing what it is supposed to. Well..
sometimes it doesn’t. ;-) So we need to debug.

The first thing you need to do now is to find where the code fails. Most of the
time this is the most difficult part of the whole development.

Once you find the code that generates the problem you have to find why it
fails.

The final phase is, of course, fixing the code.

 QA

Quality assurance is the time when the developer says: “Now it is working
and my job is done!”. It feels really great ;) QA is another test of the software.
It aims to assure that the product is working as the customer expects. This also
includes interface issues and others.

Usually this is not done by the developer. It can be done by a test script or a
QA engineer. It is important that the QA is not done by the developer, because
he is too much “in the program”. It is much easier for another guy to look at the
program by a different angle. This can make the product much more
user-friendly and easy to use. If the the product does not pass QA, it is
returned to the developer to fix the issues.

 Installation and support

The last 5%.. Of course your software should be easy to install. Otherwise
the customer could turn it down before he even tried it. Support of the
product is the last and sometimes – the most expensive step of the cycle. The
better the support – the longer your customers will
be .. your customers ;-) Now that you have a good idea of the software
development process, it is time to continue with the next part of the guide.
 Algorithm:

An algorithm is a step procedure to solve logical and mathematical problems.


A recipe is a good example of an algorithm because it says what must be
done, step by step. ... The words 'algorithm' and 'algorism' come from the
name of a Persian.

An algorithm is a set of well-defined instructions in sequence to solve a


problem.

 Qualities of a good algorithm

1. Input and output should be defined precisely.

2. Each step in the algorithm should be clear and unambiguous.

3. Algorithms should be most effective among many different ways to


solve a problem.

4. An algorithm shouldn't include computer code. Instead, the algorithm


should be written in such a way that it can be used in different programming
languages.

Examples Of Algorithms In Programming


Algorithm to add two numbers entered by the user

Step 1: Start

Step 2: Declare variables num1, num2 and sum.

Step 3: Read values num1 and num2.

Step 4: Add num1 and num2 and assign the result to sum.

sum←num1+num2

Step 5: Display sum

Step 6: Stop
 Flow chart:

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.

Advantages of Flowchart:
 Flowcharts are better way of communicating the logic of system.
 Flowcharts act as a guide for blueprint during program designed.
 Flowcharts helps in debugging process.
 With the help of flowcharts programs can be easily analyzed.
 It provides better documentation.
 Flowcharts serve as a good proper documentation.
Disadvantages of Flowchart:
 It is difficult to draw flowchart for large and complex programs.
 In this their is no standard to determine the amount of detail.
 Difficult to reproduce the flowcharts.
 It is very difficult to modify the Flowchart.
Example : Draw a flowchart to input two numbers from user and display
the largest of two numbers

// C program to find largest of two numbers


#include <stdio.h>

int main()
{
int num1, num2, largest;

/*Input two numbers*/


printf("Enter two numbers:\n");
scanf("%d%d", &num1, &num2);

/*check if a is greater than b*/


if (num1 > num2)
largest = num1;
else
largest = num2;

/*Print the largest number*/


printf("%d", largest);

return 0;
}
Output
Enter two numbers:
10 30
30
Flowchart is a diagrammatic representation of sequence of logical steps of a
program. Flowcharts use simple geometric shapes to depict processes and
arrows to show relationships and process/data flow.

Flowchart Symbols
Here is a chart for some of the common symbols used in drawing flowcharts.

Symbol Symbol Name Purpose

Used at the beginning and end of the algorithm to


Start/Stop
show start and end of the program.

Indicates processes like mathematical operations.


Process

Used for denoting program inputs and outputs.


Input/ Output

Stands for decision statements in a program,


where answer is usually Yes or No.
Decision
Shows relationships between different shapes.
Arrow

Connects two or more parts of a flowchart, which


are on the same page.
On-page Connector

Connects two parts of a flowchart which are spread


over different pages.
Off-page Connector

Guidelines for Developing Flowcharts

These are some points to keep in mind while developing a flowchart −


Flowchart can have only one start and one stop symbol
On-page connectors are referenced using numbers
Off-page connectors are referenced using alphabets
General flow of processes is top to bottom or left to right
Arrows should not cross each other

Example Flowcharts
Here is the flowchart for going to the market to purchase a pen.

Here is a flowchart to calculate the average of two numbers.


 Pseudo code:
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. Simply, we can say that it’s the cooked up
representation of an algorithm. Often at times, algorithms are represented with
the help of pseudo codes as they can be interpreted by programmers no matter
what their programming background or knowledge is. Pseudo code, as the
name suggests, is a false code or a representation of code which can be
understood by even a layman with some school level programming knowledge.
Algorithm: It’s an organized logical sequence of the actions or the approach
towards a particular problem. A programmer implements an algorithm to solve a
problem. Algorithms are expressed using natural verbal but somewhat technical
annotations.
Pseudo code: It’s simply an implementation of an algorithm in the form of
annotations and informative text written in plain English. It has no syntax like
any of the programming language and thus can’t be compiled or interpreted by
the computer.

Advantages of Pseudocode
 Improves the readability of any approach. It’s one of the best
approaches to start implementation of an algorithm.
 Acts as a bridge between the program and the algorithm or flowchart.
Also works as a rough documentation, so the program of one developer
can be understood easily when a pseudo code is written out. In industries,
the approach of documentation is essential. And that’s where a
pseudo-code proves vital.
 The main goal of a pseudo code is to explain what exactly each line of a
program should do, hence making the code construction phase easier for
the programmer.

How to write a Pseudo-code?

1. Arrange the sequence of tasks and write the pseudocode accordingly.


2. Start with the statement of a pseudo code which establishes the main
goal or the aim.
Example:

This program will allow the user to check


the number whether it's even or odd.

3. The way the if-else, for, while loops are indented in a program, indent
the statements likewise, as it helps to comprehend the decision control
and execution mechanism. They also improve the readability to a great
extent.
Example:

if "1"
print response
"I am case 1"

if "2"
print response
"I am case 2"

4. Use appropriate naming conventions. The human tendency follows the


approach to follow what we see. If a programmer goes through a pseudo
code, his approach will be the same as per it, so the naming must be
simple and distinct.
5. Use appropriate sentence casings, such as CamelCase for methods,
upper case for constants and lower case for variables.
6. Elaborate everything which is going to happen in the actual code. Don’t
make the pseudo code abstract.
7. Use standard programming structures such as ‘if-then’, ‘for’, ‘while’,
‘cases’ the way we use it in programming.
8. Check whether all the sections of a pseudo code is complete, finite and
clear to understand and comprehend.
9. Don’t write the pseudo code in a complete programmatic manner. It is
necessary to be simple to understand even for a layman or client, hence
don’t incorporate too many technical terms.

Example:Let’s have a look at this code

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy