Download as pdf or txt
Download as pdf or txt
You are on page 1of 34

UNIT 1 IT18101 PROGRAMMING FOR PROBLEM SOLVING

Unit I
Introduction
Syllabus

Simple model of a Computer – Hardware – Software – Data Representation, Introduction to


Computer Networks and Internet, Problem Solving Techniques – Bottom up design and top
down design - applications, Introduction to Algorithms and Flow Chart.

1. COMPUTER
An automatic electronic apparatus for making calculations or controlling operations that are
expressible in numerical or logical terms.

2. ANATOMY OF A COMPUTER/ SIMPLE MODEL OF A COMPUTER/ BASIC


ORGANISATION OF A COMPUTER
A computer can accept input , process or store data and produce output according to a set of
instructions which are fed into it. A computer can be divided into two components: Hardware
and software. Hardware is the tangible part of the computer where as software is intangible set of
instructions that control the hardware and make it perform specific task.

2.1 Hardware
Hardware is the physical components of the computer that includes all mechanical, electrical and
electronic parts attached to it. A computer consists of major components as follows:

SVCE Page 1
UNIT 1 IT18101 PROGRAMMING FOR PROBLEM SOLVING

Input and Output devices , central processing unit, memory unit and storage devices, interface
unit.

2.1.1 Input devices:


Input devices are electronic or electro-mechanical equipment that provide a means of
communicating with the computer system for feeding input data and instructions. The data and
instructions are typed, submitted or transmitted to a computer through input devices. Most
common input devices are:

Keyboard
A computer keyboard is one of the primary input devices used with a computer that looks similar
to those found on electric typewriters, but with some additional keys. Keyboards allow you to
input letters, numbers, and other symbols into a computer that can serve as commands or be used
to type text.

Mouse
A mouse is the pointing device attached to a computer. It is used to move the cursor around the
screen and to point to an object for the purpose of selecting or activating objects on graphical
interface.

Scanner
A scanner is a device that captures pictures or documents so that they can be stored in storage
devices, seen on a video screen, modified suitably, transported to other computers or printed on a
printer.

2.1.2 Output devices


Output devices mirror the input data or show the output results of the operations on the input
data or print the data. Some of the common output devices are

Monitor
The monitor displays the computer's user interface and open programs, allowing the user to
interact with the computer, typically using the keyboard and mouse.

Printer
Printer is a device that prints any data, report, documents, picture, diagrams etc.

2.1.3 Central Processing unit


CPU is the brain of the computer. Most of the processing takes place in CPU. During processing,
it locates and executes program instructions. It also fetches data from memory and i/o devices
and sends data back. CPU is divided into different functional units which are described below:

SVCE Page 2
UNIT 1 IT18101 PROGRAMMING FOR PROBLEM SOLVING

Registers
These are high-speed storage devices. It contains a set of general purpose registers that are used
for temporary storage of data values as needed during processing.
Special purpose registers are reserved for special purpose. Instruction Register (IR) holds the
current instruction to be executed. Program Counter (PC) is a register that holds the address of
the next instruction to be executed.

Arithmetic Logic Unit (ALU)


It is the part of the CPU that performs arithmetic operations, such as addition and subtraction as
well as logical operations, such as comparing two numbers.

Control Unit (CU)


This coordinates the processing by controlling the transfer of data and instructions between main
memory and registers in CPU.
It also coordinates the execution of Arithmetic Logic Unit (ALU) to perform operations on data
stored in particular registers.
It consists of

an instruction decoding circuit that interprets what action should be performed.
a control and timing circuit detects all the other parts of the computer by producing the
respective control signals.

2.1.4 Memory Unit


A storage area is needed in a computer to store instructions and data either temporarily or
permanently , so that subsequent retrieval of the instructions and data can be possible on
demand.
CPU uses registers exclusively to store and manipulate data and instruction during the
processing. Apart from registers, there are two types of memory as follows:

Primary Memory is the area where data and programs stored while the program is being
executed along with the data .

Secondary memory provides large, non volatile and inexpensive storage for programs and
data.
2.1.5 Interface Unit
The interface unit interconnects the CPU with memory and also with the various input / output
devices. The instruction and data move between the CPU and other hardware components
through interface unit.

SVCE Page 3
UNIT 1 IT18101 PROGRAMMING FOR PROBLEM SOLVING

2.2 Software
Software provides the instructions that tells the hardware exactly what is to be performed and in
what order. This set of instruction is sequenced and organised in a computer program. A program
is a series of instructions which is intended to direct a computer to perform certain functions and
executed by the processor.
Software is generally categorised as follows:

System software is designed to facilitate and coordinate the use of computer by making
hardware operational. Examples: Operating system, language translator, loader, linker.
Application program is designed to perform specific tasks for the user. Example Word,
Excel, AutoCAD, Internet explorer.

3. COMPUTER NETWORK

A computer network is a network of geographically distributed multiple computers connected in


a manner to exchange information among them. Sharing of resources, and sharing of processing
load are some of the major objectives of a computer network.

3.1 Basic elements of a communication system

Communication is the process of transferring messsages from one point to another. The three
basic elements of a communication system are:

1. Sender – which creates the message to be transmitted.


2. Medium – which carries the message
3. Receiver – which receives the message

3.2 Data Transmission modes

There are three ways or modes of transmitting data from one point to another. These are simplex,
half duplex and full duplex.

SVCE Page 4
UNIT 1 IT18101 PROGRAMMING FOR PROBLEM SOLVING

3.2.1 Simplex:

Communication takes place in only one direction.

Examples of simplex include radio broadcasting, television broadcasting, computer to printer

communication, and keyboard to computer connections.

3.2.2 Half Duplex

In half duplex mode, data can be transmitted in both directions on a signal carrier except not at
the same time. At a certain point, it is actually a simplex channel whose transmission direction
can be switched. Walkie-talkie is a typical half duplex device. It has a ―push-to-talk‖ button
which can be used to turn on the transmitter but turn off the receiver. Therefore, once you push
the button, you cannot hear the person you are talking to but your partner can hear you. An
advantage of half-duplex is that the single track is cheaper than the double tracks.

3.2.3 Full Duplex

A full duplex communication channel is able to transmit data in both directions on a signal
carrier at the same time. It is constructed as a pair of simplex links that allows bidirectional
simultaneous transmission. Take telephone as an example, people at both ends of a call can
speak and be heard by each other at the same time because there are two communication paths
between them. Thus, using the full duplex mode can greatly increase the efficiency of
communication.

SVCE Page 5
UNIT 1 IT18101 PROGRAMMING FOR PROBLEM SOLVING

3.3Data Transmission speed

The speed with which data can be transmitted from one device to another. Data rates are often
measured in megabits (million bits) or megabytes (million bytes) per second. These are usually
abbreviated as Mbps and MBps,respectively.

A term used to describe the data handling capacity of a communication system is bandwidth.
Bandwidth is the range of frequencies that is available for the transmission of data. The
communication data transfer rate is measured in a unit called baud. Baud is identical to bits per
second. Depending on their transmission speeds, communication channels are grouped into the
following three basic categories:

3.3.1Narrow band:

Narrowband or subvoice grade channels range in speed from 45 to 300 baud. They are used for
handling low data volumes and are adequate for low-speed devices. They are mainly for
telegraphs lines and low speed terminals.

3.3.2Voice band:

Voice band channels handle moderate data volumes and can transmit data at speeds upto 9600 baud.
Their major application is ordinary telephone voice communication. They are also used for data
transmission from slow I/O devices to CPU or vice-versa.

3.3.3Broad band:

Broadband are used when large volumes of data are to be transmitted at high speed. These systems
provide data transmission rates of 1 million baud or more.

3.4Data Transmission media

3.4.1Transmission media is a pathway that carries the information from sender to receiver. We use
different types of cables or waves to transmit data. Data is transmitted normally through electrical or
electromagnetic signals.

3.4.1Types of Transmission Media

Transmission media is broadly classified into two groups.


SVCE Page 6
UNIT 1 IT18101 PROGRAMMING FOR PROBLEM SOLVING

 Wired or Guided Media or Bound Transmission Media : Bound transmission media are the
cables that are tangible or have physical existence and are limited by the physical
geography. Popular bound transmission media in use are twisted pair cable, co-axial cable and
fiber optical cable. Each of them has its own characteristics like transmission speed, effect of
noise, physical appearance, cost etc.

 Wireless or Unguided Media or Unbound Transmission Media : Unbound


transmission media are the ways of transmitting data without using any cables. These
media are not bounded by physical geography. This type of transmission is called
Wireless communication. Nowadays wireless communication is becoming popular.
Wireless LANs are being installed in office and college campuses. This transmission
uses Microwave, Radio wave, Infra red are some of popular unbound transmission media.

Twisted Pair (Copper Conductors)

A twisted pair is a pair of copper wires, with diameters of 0.4-0.8 mm, twisted together and
wrapped with a plastic coating. The twisting reduces the electrical noise and the error rate of the
data transmission. Each conductor is separately insulated by some low-smoke and fires retardant
substance.

Co-axial Cable

Coaxial cable is a robust shielded copper wire two-conductor cable in which a solid center
conductor runs concentrically (coaxial) inside a solid outer circular conductor.
SVCE Page 7
UNIT 1 IT18101 PROGRAMMING FOR PROBLEM SOLVING

Coaxial cable includes shield for improved performance and therefore is expensive. Cable TV
networks use coaxial cable. Local Area Networks can operate over coaxial cable to the
10BASE5, 10BASE2 and 10BASET specifications. In general, coaxial cable enables longer
distance transmission at higher data rates than twisted pair cable but this is more expensive.

There are two types of coaxial cables.


Baseband: It transmits a single signal at a time at very high speed. The signal on baseband cable
must be amplified at a specified distances. It is used for local area networks.

Broadband: It can transmit many simultaneous signals using different frequencies.

Advantages:

 High Bandwidth
 Better noise Immunity
 Easy to install and expand
 Inexpensive
Disadvantages:

 Single cable failure can disrupt the entire network

Fiber-Optics Cable

A cable with central glass tube covered with protective shield which transmit data using photons
is fiber optics cable. These cables transmit data via concentrated bursts of laser beams which are
carried through bundles of hair thin glass fibers.

They have advantages over electronic cables in transmission speed and volume. This technology
has revolutionized telecommunication applications which used electronic cables. Fiber optics
cables as free from electro-magnetic interference as well as wire tapping. fiber optics cable
considered a broad band communication channel

Advantages:
Increased capacity and bandwidth

Light weight

Less signal attenuation


Disadvantages:

Difficult to install and maintain

High cost
SVCE Page 8
UNIT 1 IT18101 PROGRAMMING FOR PROBLEM SOLVING

Fragile
Radiowaves
These are easy to generate and can penetrate through buildings.The sending and receiving
antennas need not be aligned. Frequency Range:3KHz – 1GHz. AM and FM radios and cordless
phones use Radiowaves for transmission.

Microwaves
It is a line of sight transmission i.e. the sending and receiving antennas need to be properly
aligned with each other. The distance covered by the signal is directly proportional to the height
of the antenna. Frequency Range:1GHz – 300GHz. These are majorly used for mobile phone
communication and television distribution.

Infrared
Infrared waves are used for very short distance communication. They cannot penetrate through
obstacles. This prevents interference between systems. Frequency Range:300GHz – 400THz. It
is used in TV remotes, wireless mouse, keyboard, printer, etc.

4.NETWORK TOPOLOGIES

Network Topology is the schematic description of a network arrangement, connecting various


nodes(sender and receiver) through lines of connection.

4.1Types Of Network Topologies

4.1.1BUS Topology

Bus topology is a network type in which every computer and network device is connected to
single cable. When it has exactly two endpoints, then it is called Linear Bus topology.

Features of Bus Topology

 It transmits data only in one direction.

SVCE Page 9
UNIT 1 IT18101 PROGRAMMING FOR PROBLEM SOLVING

 Every device is connected to a single cable


Advantages of Bus Topology

 It is cost effective.
 Cable required is least compared to other network topology.
 Used in small networks.
 It is easy to understand.
 Easy to expand joining two cables together.
Disadvantages of Bus Topology

 Cables fails then whole network fails.


 If network traffic is heavy or nodes are more the performance of the network decreases.
 Cable has a limited length.
 It is slower than the ring topology.

4.1.2RING Topology

It is called ring topology because it forms a ring as each computer is connected to another

computer, with the last one connected to the first. Exactly two neighbours for each device.

Features of Ring Topology


A number of repeaters are used for Ring topology with large number of nodes, because if
someone wants to send some data to the last node in the ring topology with 100 nodes, then the
data will have to pass through 99 nodes to reach the 100th node. Hence to prevent data loss
repeaters are used in the network.

SVCE Page 10
UNIT 1 IT18101 PROGRAMMING FOR PROBLEM SOLVING

The transmission is unidirectional, but it can be made bidirectional by having 2 connections


between each Network Node, it is called Dual Ring Topology.

In Dual Ring Topology, two ring networks are formed, and data flow is in opposite direction in
them. Also, if one ring fails, the second ring can act as a backup, to keep the network up.

Data is transferred in a sequential manner that is bit by bit. Data transmitted, has to pass through
each node of the network, till the destination node.

Advantages of Ring Topology

 Transmitting network is not affected by high traffic or by adding more nodes, as only the
nodes having tokens can transmit data.
 Cheap to install and expand

Disadvantages of Ring Topology

 Troubleshooting is difficult in ring topology.


 Adding or deleting the computers disturbs the network activity.
 Failure of one computer disturbs the whole network.

4.1.3STAR Topology

In this type of topology all the computers are connected to a single hub through a cable. This hub

is the central node and all others nodes are connected to the central node.

Features of Star Topology

 Every node has its own dedicated connection to the hub.


 Hub acts as a repeater for data flow.

SVCE Page 11
UNIT 1 IT18101 PROGRAMMING FOR PROBLEM SOLVING

 Can be used with twisted pair, Optical Fibre or coaxial cable.

Advantages of Star Topology

 Fast performance with few nodes and low network traffic.


 Hub can be upgraded easily.
 Easy to troubleshoot.
 Easy to setup and modify.
 Only that node is affected which has failed, rest of the nodes can work smoothly.

Disadvantages of Star Topology

 Cost of installation is high.


 Expensive to use.
 If the hub fails then the whole network is stopped because all the nodes depend on the
hub.
 Performance is based on the hub that is it depends on its capacity

4.1.4MESH Topology

It is a point-to-point connection to other nodes or devices. All the network nodes are connected
to each other. Mesh has n(n-1)/2 physical channels to link n devices.

SVCE Page 12
UNIT 1 IT18101 PROGRAMMING FOR PROBLEM SOLVING

Features of Mesh Topology

 Fully connected.
 Robust.
 Not flexible.

Advantages of Mesh Topology

 Each connection can carry its own data load.


 It is robust.
 Fault is diagnosed easily.
 Provides security and privacy.

Disadvantages of Mesh Topology

 Installation and configuration is difficult.


 Cabling cost is more.
 Bulk wiring is required.

4.1.5TREE Topology

It has a root node and all other nodes are connected to it forming a hierarchy. It is also called

hierarchical topology. It should at least have three levels to the hierarchy.

Features of Tree Topology

 Ideal if workstations are located in groups.


 Used in Wide Area Network.
Advantages of Tree Topology

 Extension of bus and star topologies.


 Expansion of nodes is possible and easy.

SVCE Page 13
UNIT 1 IT18101 PROGRAMMING FOR PROBLEM SOLVING

 Easily managed and maintained.


 Error detection is easily done.
Disadvantages of Tree Topology

 Heavily cabled.
 Costly.
 If more nodes are added maintenance is difficult.
 Central hub fails, network fails.

4.1.6HYBRID Topology

It is two different types of topologies which is a mixture of two or more topologies. For example
if in an office in one department ring topology is used and in another star topology is used,
connecting these topologies will result in Hybrid Topology (ring topology and star topology).

Features of Hybrid Topology

 It is a combination of two or topologies


 Inherits the advantages and disadvantages of the topologies included

SVCE Page 14
UNIT 1 IT18101 PROGRAMMING FOR PROBLEM SOLVING

Advantages of Hybrid Topology

 Reliable as Error detecting and trouble shooting is easy.


 Effective.
 Scalable as size can be increased easily.
 Flexible.
Disadvantages of Hybrid Topology

 Complex in design.
 Costly.

5.NETWORK DEVICES (HUB, REPEATER, BRIDGE, SWITCH, ROUTER,


GATEWAYS AND BROUTER)

5.1 Repeater – A repeater operates at the physical layer. Its job is to regenerate the signal over
the same network before the signal becomes too weak or corrupted so as to extend the length to
which the signal can be transmitted over the same network. An important point to be noted about
repeaters is that they do not amplify the signal. When the signal becomes weak, they copy the
signal bit by bit and regenerate it at the original strength. It is a 2 port device.

5.2 Hub – A hub is basically a multiport repeater. A hub connects multiple wires coming from
different branches, for example, the connector in star topology which connects different stations.
Hubs cannot filter data, so data packets are sent to all connected devices. In other
words, collision domain of all hosts connected through Hub remains one. Also, they do not have
intelligence to find out best path for data packets which leads to inefficiencies and wastage.

5.3 Bridge – A bridge operates at data link layer. A bridge is a repeater, with add on
functionality of filtering content by reading the MAC addresses of source and destination. It is
also used for interconnecting two LANs working on the same protocol. It has a single input and
single output port, thus making it a 2 port device.

5.4 Switch – A switch is a multi port bridge with a buffer and a design that can boost its
efficiency(large number of ports imply less traffic) and performance. Switch is data link layer
device. Switch can perform error checking before forwarding data, that makes it very efficient as
it does not forward packets that have errors and forward good packets selectively to correct port
only.

5.5 Routers – A router is a device like a switch that routes data packets based on their IP
addresses. Router is mainly a Network Layer device. Routers normally connect LANs and
WANs together and have a dynamically updating routing table based on which they make
decisions on routing the data packets. Router divide broadcast domains of hosts connected
through it.
SVCE Page 15
UNIT 1 IT18101 PROGRAMMING FOR PROBLEM SOLVING

5.6 Gateway – A gateway is a passage to connect two networks together that may work upon
different networking models. They basically works as the messenger agents that take data from
one system, interpret it, and transfer it to another system. Gateways are also called protocol
converters and can operate at any network layer. Gateways are generally more complex than
switch or router.

6. TYPES OF COMMUNICATION NETWORKS

Communication Networks can be of following 3 types:

 Local Area Network (LAN)


 Metropolitan Area Network (MAN)
 Wide Area Network (WAN)

SVCE Page 16
UNIT 1 IT18101 PROGRAMMING FOR PROBLEM SOLVING

6.1Local Area Network (LAN)

It is also called LAN and designed for small physical areas such as an office, group of buildings
or a factory. LANs are used widely as it is easy to design and to troubleshoot. Personal
computers and workstations are connected to each other through LANs.

LAN can be a simple network like connecting two computers, to share files and network among
each other while it can also be as complex as interconnecting an entire building.

LAN networks are also widely used to share resources like printers, shared hard-drive etc.

Characteristics of LAN

 LAN's are private networks, not subject to tariffs or other regulatory controls.
 LAN's operate at relatively high speed when compared to the typical WAN.
 There are different types of Media Access Control methods in a LAN, the prominent ones
are Ethernet, Token ring.
 It connects computers in a single building, block or campus, i.e. they work in a restricted
geographical area.

Advantages of LAN

 Resource Sharing
 Software Applications Sharing
 Easy and Cheap Communication
SVCE Page 17
UNIT 1 IT18101 PROGRAMMING FOR PROBLEM SOLVING

 Centralized Data
 Data Security
 Internet Sharing

Disadvantages of LAN

 High Setup Cost


 Privacy Violations
 Data Security Threat
 LAN Maintenance Job
 Covers Limited Area

6.2Metropolitan Area Network (MAN)

Characteristics of MAN

 It generally covers towns and cities (50 km)


 Communication medium used for MAN are optical fibers, cables etc.
 Data rates adequate for distributed computing applications.

Advantages of MAN

 Extremely efficient and provide fast communication via high-speed carriers, such as fibre
optic cables.
 It provides a good back bone for large network and provides greater access to WANs.
 The dual bus used in MAN helps the transmission of data in both directions

SVCE Page 18
UNIT 1 IT18101 PROGRAMMING FOR PROBLEM SOLVING

simultaneously.
 A MAN usually encompasses several blocks of a city or an entire city.

Disadvantages of MAN

 More cable required for a MAN connection from one place to another.
 It is difficult to make the system secure from hackers and industrial espionage(spying)
graphical regions.

6.3 Wide Area Network (WAN)

It is used for the network that covers large distance such as cover states of a country. It is not
easy to design and maintain. Communication medium used by WAN are PSTN or Satellite links.
WAN operates on low data rates.

Characteristics of WAN

 It generally covers large distances(states, countries, continents).


 Communication medium used are satellite, public telephone networks which are
connected by routers.

Advantages of WAN

 Covers a large geographical area so long distance business can connect on the one
network.
 Shares software and resources with connecting workstations.

SVCE Page 19
UNIT 1 IT18101 PROGRAMMING FOR PROBLEM SOLVING

 Messages can be sent very quickly to anyone else on the network. These messages can
have picture, sounds or data included with them(called attachments).
 Expensive things(such as printers or phone lines to the internet) can be shared by all the
computers on the network without having to buy a different peripheral for each computer.
 Everyone on the network can use the same data. This avoids problems where some users
may have older information than others.

Disadvantages of WAN

 Need a good firewall to restrict outsiders from entering and disrupting the network.
 Setting up a network can be an expensive, slow and complicated. The bigger the network
the more expensive it is.
 Once set up, maintaining a network is a full-time job which requires network supervisors
and technicians to be employed.
 Security is a real issue when many different people have the ability to use information
from other computers. Protection against hackers and viruses adds more complexity and
expense.

7. INTERNET

The Internet is a global system of interconnected computer networks that use the standard
Internet protocol suite (TCP/IP) to serve billions of users worldwide. It is a network of networks
that consists of millions of private, public, academic, business, and government networks, of
local to global scope, that are linked by a broad array of electronic, wireless and optical
networking technologies. The Internet carries a vast range of information resources and services,
such as the interlinked hypertext documents of the World Wide Web (WWW) and the
infrastructure to support electronic mail.

7.1 Uses of Internet

Internet has been the most useful technology of the modern times which helps us not only in our
daily lives, but also our personal and professional lives developments. The internet helps us
achieve this in several different ways.

For the students and educational purposes the internet is widely used to gather information so as
to do the research or add to the knowledge of various subjects. Even the business professionals
and the professionals like doctors, access the internet to filter the necessary information for their
use. The internet is therefore the largest encyclopedia for everyone, in all age categories. The
internet has served to be more useful in maintaining contacts with friends and relatives who live
abroad permanently.

SVCE Page 20
UNIT 1 IT18101 PROGRAMMING FOR PROBLEM SOLVING

7.2 Advantages of Internet:

 E-mail: Email is now an essential communication tools in business. With e-mail you can
send and receive instant electronic messages, which works like writing letters. Your
messages are delivered instantly to people anywhere in the world, unlike traditional mail
that takes a lot of time. Email is free, fast and very cheap when compared to telephone,
fax and postal services.
 24 hours a day 7 days a week: Internet is available, 24x7 days for usage.
 Information: Information is probably the biggest advantage internet is offering. There is
a huge amount of information available on the internet for just about every subject,
ranging from government law and services, trade fairs and conferences, market
information, new ideas and technical support. You can almost find any type of data on
almost any kind of subject that you are looking for by using search engines like google,
yahoo, msn, etc.
 Online Chat: You can access many ‗chat rooms‘ on the web that can be used to meet
new people, make new friends, as well as to stay in touch with old friends.
 Services: Many services are provided on the internet like net banking, job searching,
purchasing tickets, hotel reservations, guidance services on array of topics engulfing
every aspect of life.
 Communities: Communities of all types have sprung up on the internet. Its a great way
to meet up with people of similar interest and discuss common issues.
 E-commerce: Along with getting information on the Internet, you can also shop online.
There are many online stores and sites that can be used to look for products as well as
buy them using your credit card. You do not need to leave your house and can do all
your shopping from the convenience of your home. It has got a real amazing and wide
range of products from household needs, electronics to entertainment.
 Entertainment: Internet provides facility to access wide range of Audio/Video songs,
plays films. Many of which can be downloaded. One such popular website is YouTube.
 Software Downloads: You can freely download innumerable, softwares like utilities,
games, music, videos, movies, etc from the Internet.

7.3 Limitations of Internet

 Theft of Personal information: Electronic messages sent over the Internet can be easily
snooped and tracked, revealing who is talking to whom and what they are talking about.
If you use the Internet, your personal information such as your name, address, credit
card, bank details and other information can be accessed by unauthorized persons. If you
use a credit card or internet banking for online shopping, then your details can also be
‗stolen‘.
 Negative effects on family communication: It is generally observed that due to more
time spent on Internet, there is a decrease in communication and feeling of togetherness
among the family members.
 Internet addiction: There is some controversy over whether it is possible to actually be
addicted to the Internet or not. Some researchers, claim that it is simply people trying to
SVCE Page 21
UNIT 1 IT18101 PROGRAMMING FOR PROBLEM SOLVING

escape their problems in an online world.


 Virus threat: Computers are mainly getting these viruses from the Internet. Virus is a
program which disrupts the normal functioning of your computer systems. Computers
attached to internet are more prone to virus attacks and they can end up into crashing
your whole hard disk.
 Spamming: It is often viewed as the act of sending unsolicited email. This multiple or
vast emailing is often compared to mass junk mailings. It needlessly obstruct the entire
system. Most spam is commercial advertising, often for dubious products, get-rich-
quick schemes, or quasi-legal services. Spam costs the sender very little to send — most
of the costs are paid for by the recipient or the carriers rather than by the sender

7.4 SERVICES OF INTERNET -E-mail, FTP, Telnet

7.4.1 E-Mail (Electronic Mail)

E-mail or Electronic mail is a paperless method of sending messages, notes or letters from one
person to another or even many people at the same time via Internet. E-mail is very fast
compared to the normal post. E-mail messages usually take only few seconds to arrive at their
destination. One can send messages anytime of the day or night, and, it will get delivered
immediately. You have the privilege of sending something extra such as a file, graphics, images
etc. along with your e-mail. The biggest advantage of using email is that it is cheap, especially
when sending messages to other states or countries and at the same time it can be delivered to a
number of people around the world. It allows you to compose note, get the address of the
recipient and send it. Once the mail is received and read, it can be forwarded or replied. One can
even store it for later use, or delete. In e-mail even the sender can request for delivery receipt and
read receipt from the recipient.

Features of E-mail:

 One-to-one or one-to-many communications


 Instant communications
 Physical presence of recipient is not required
 Most inexpensive mail services, 24-hours a day and seven days a week
 Encourages informal communications

7.4.2 FTP (File Transfer Protocol)

File Transfer Protocol, is an Internet utility software used to uploaded and download files. It
gives access to directories or folders on remote computers and allows software, data and text
files to be transferred between different kinds of computers.

SVCE Page 22
UNIT 1 IT18101 PROGRAMMING FOR PROBLEM SOLVING

FTP works on the basis of same principle as that of Client/Server. FTP ―Client‖ is a program
running on your computer that enables you to communicate with remote computers. The FTP
client takes FTP command and sends these as requests for information from the remote computer
known as FTP servers. To access remote FTP server it is required, but not necessary to have an
account in the FTP server. When the FTP client gets connected, FTP server asks for the
identification in terms of User Login name and password of the FTP client. If one does not have
an account in the remote FTP server, still he can connect to the server using anonymous login.

Using anonymous login anyone can login in to a FTP server and can access public archives;
anywhere in the world, without having an account. One can easily Login to the FTP site with the
username anonymous and e-mail address as password.

Objectives of FTP :

 Provide flexibility and promote sharing of computer programs, files and data
 Transfer data reliably and more efficiently over network
 Encourage implicit or indirect use of remote computers using Internet
 Shield a user from variations in storage systems among hosts.
Telnet (Remote Computing)

Telnet or remote computing is telecommunication utility software, which uses available


telecommunication facility and allows you to become a user on a remote computer. Once you

SVCE Page 23
UNIT 1 IT18101 PROGRAMMING FOR PROBLEM SOLVING

gain access to remote computer, you can use it for the intended purpose. The TELNET works in
a very step by step procedure. The commands typed on the client computer are sent to the local
Internet Service Provider (ISP), and then from the ISP to the remote computer that you have
gained access. Most of the

ISP provides facility to TELENET into your own account from another city and check your e-
mail while you are travelling or away on business.

8. PROBLEM SOLVING TECHNIQUES

A computer cannot solve a problem on its own. One has to provide step by step solutions of the
problem to the computer. In fact, the task of problem solving is not that of the computer. It is the
programmer who has to write down the solution to the problem in terms of simple operations
which the computer can understand and execute. In order to solve a problem by the computer,
one has to pass though certain stages or steps.

They are
1. Understanding the problem
2. Analyzing the problem
3. Developing the solution
4. Coding and implementation.

1. Understanding the problem: Here we try to understand the problem to be solved in totally.
Before proceeding to the next stage or step, we should be absolutely sure about the objectives of
the given problem.

2. Analyzing the problem: After understanding thoroughly the problem to be solved, we look
into different ways of solving the problem and evaluate each of these methods. The idea here is
to search an appropriate solution to the problem under consideration. The end result of this stage
is a broad overview of the sequence of operations that are to be carried out to solve the given
problem.

3. Developing the solution: Here the overview of the sequence of operations that was the result
of analysis stage is expanded to form a detailed step by step solution to the problem under
consideration.

4. Coding and implementation: The last stage of the problem solving is the conversion of the
detailed sequence of operations in to a language that the computer can understand. Here each
step is converted to its equivalent instruction or instructions in the computer language that has
been chosen for the implementation.

8.1 Top-Down Design

SVCE Page 24
UNIT 1 IT18101 PROGRAMMING FOR PROBLEM SOLVING

We know that a system is composed of more than one sub-systems and it contains a number of
components. Further, these sub-systems and components may have their own set of sub-system
and components and creates hierarchical structure in the system.

Top-down design takes the whole software system as one entity and then decomposes it to
achieve more than one sub-system or component based on some characteristics. Each sub-system
or component is then treated as a system and decomposed further. This process keeps on running
until the lowest level of system in the top-down hierarchy is achieved.

Top-down design starts with a generalized model of system and keeps on defining the more
specific part of it. When all components are composed the whole system comes into existence.

Top-down design is more suitable when the software solution needs to be designed from scratch
and specific details are unknown.

Top down program design is an approach to program design that starts with the general concept
and repeatedly breaks it down into its component parts. In other words, it starts with the abstract
and continually subdivides it until it reaches the specific. Consider creating the prime
factorization of a number like 1540. The steps involved might look like:

 1540
 2 x 770
 2 x 2 x 385
 2 x 2 x 5 x 77
 2 x 2 x 5 x 7 x 11

Top down program design works the same way. We start with the overall objective and wind up
with a series of steps needed to accomplish it.

Top-down analysis, therefore, simplifies or reduces the complexity of the process of problem
solving. It is not limited by the type of program. Top-down analysis is a general method for
attending to any problem. It provides a strategy that has to be followed for solving all problems.
There are two essential ideas in top-down analysis:
 subdivision of a problem
 hierarchy of tasks

Subdivision of a problem means breaking a big problem into two or more smaller problems.
Therefore, to solve the big problem, first these smaller problems have to be solved. Top-down
analysis does not simply divide a problem into two or more smaller problems.It goes further than
that. Each of these smaller problems is further subdivided. This process continues downwards,
creating a hierarchy of tasks, from one level to the next, until no further break up is possible.

The four basic steps to top-down analysis are as follows:


Step 1: Define the complete scope of the problem to determine the basic requirement for its
solution. Three factors must be considered in the definition of a programming problem.
SVCE Page 25
UNIT 1 IT18101 PROGRAMMING FOR PROBLEM SOLVING

Input: What data is required to be processed by the program?


Process: What must be done with the input data? What type of processing is required?
Output: What information should the program produce? In what form should it be presented?

Step 2: Based on the definition of the problem, divide the problem into two or more separate
parts.
Step 3: Carefully define the scope of each of these separate tasks and subdivide them further, if
necessary, into two or more smaller tasks.
Step 4: Repeat step 3. Every step at the lowest level describes a simple task, which cannot be
broken further.

8.2 Bottom-up Design

The bottom up design model starts with most specific and basic components. It proceeds with
composing higher level of components by using basic or lower level components. It keeps
creating higher level components until the desired system is not evolved as one single
component. With each higher level, the amount of abstraction is increased.

Bottom-up strategy is more suitable when a system needs to be created from some existing
system, where the basic primitives can be used in the newer system.

Bottom up program design works in the exact opposite way. It starts with the component parts
and repeatedly combines them to achieve the general concept. In other words, it starts with the
specific and continually combines it until it reaches the abstract. For example, consider the
factorization from the previous section. For bottom up design the steps involved might look like:

 2 x 2 x 5 x 7 x 11
 2 x 2 x 5 x 77
 2 x 2 x 385
 2 x 770
 1540

8.3 Difference Between Top-down Approach and Bottom-up Approach

Top-down Approach Bottom-up Approach


A top-down approach is essentially the breaking A bottom-up approach is the piecing together of
down of a program to gain insight into its module (or small program) to give rise to more
compositional small program (or module) in a complex program, thus making the original
reverse engineering fashion. modules of the emergent program.
Structure / procedure oriented programming Object oriented programming languages like
languages like C programming language follows C++ and JAVA programming language follows
top-down approach. bottom-up approach.
A top-down approach begins with high level A bottom-up approach begins with low level
design and ends with low level design or design or development and ends with high level
development. design.
SVCE Page 26
UNIT 1 IT18101 PROGRAMMING FOR PROBLEM SOLVING

In top-down approach, main function is written In bottom-up approach, code is developed from
first and all sub functions are called from main modules and then these modules are integrated
function thus, sub-functions are written based with main function
on the requirement

9. ALGORITHM

An algorithm is an effective procedure for solving a problem in a finite number of steps. A


program is composed of algorithm and data. The four common ways of representing an
algorithm are the Step-form, Pseudo-code, Flowchart and Nassi-Schneiderman.

9.1 Key Features of an Algorithm

An algorithm can be stated using three basic constructs: sequence, decision, and repetition.

Sequence
Sequence means that each step or process in the algorithm is executed in the specified order.

The decision constructs— if ... then, if ... then ... else ...
In algorithms the outcome of a decision is either true or false; there is no state in between.
The outcome of the decision is based on some condition that can only result in a true or false
value. For example, if today is Friday then collect pay is a decision and the decision takes the
general form:

if proposition then process

A proposition, in this sense, is a statement, which can only be true or false. It is either true that
‗today is Friday‘ or it is false that ‗today is not Friday‘. It can not be both true and false. If the
proposition is true, then the process or procedure that follows the then is executed.

The decision can also be stated as:

if proposition then process1


else process2

This is the if … then … else … form of the decision. This means that if the proposition is true
then execute process1, else, or otherwise, execute process2 The first form of the decision if
proposition then process has a null else, that is, there is no else.

The repetition constructs— repeat and while


Repetition can be implemented using constructs like the repeat loop, while loop, and if.. then ..
goto .. loop.The Repeat loop is used to iterate or repeat a process or sequence of processes until
some condition becomes true.
SVCE Page 27
UNIT 1 IT18101 PROGRAMMING FOR PROBLEM SOLVING

It has the general form:


Repeat
Process1
Process2
..............
………..
ProcessN
Until proposition

Example:

Repeat
Fill water in kettle
Until kettle is full
The process is ‗Fill water in kettle,‘ the proposition is ‗kettle is full‘.
The Repeat loop does some processing before testing the state of the proposition. What happens
though if in the above example the kettle is already full? If the kettle is already full at the start of
the Repeat loop, then filling more water will lead to an overflow. This is a drawback of the
Repeat construct.
In such a case the while loop is more appropriate. The above example with the while loop is
shown as follows:
while kettle is not full
fill water in kettle

Since the decision about the kettle being full or not is made before filling water, the possibility of
an overflow is eliminated. The while loop finds out whether some condition is true before
repeating a process or a sequence of processes.

If the condition is false, the process or the sequence of processes is not executed. The general
form of while loop is:

while proposition
begin

Process 1

Process 2
………..
………...
Process N
end

The if .. then goto .. is also used to repeat a process or a sequence of processes until the given
proposition is false. In the kettle example, this construct would be implemented as follows:

SVCE Page 28
UNIT 1 IT18101 PROGRAMMING FOR PROBLEM SOLVING

1. Fill some water in kettle


2. if kettle not full then goto 1

So long as the proposition ‗kettle not full‘ is true the process, ‗fill some water in kettle‘ is
repeated. The general form of if .. then goto .. is:

Process1
Process2
……….
……….
ProcessN
if proposition then goto Process1

Termination
The algorithm must end after a finite number of steps.

Correctness
The prepared algorithm needs to be verified for its correctness. Correctness means how easily its
logic can be argued to meet the algorithm‘s primary goal. This requires the algorithm to be made
in such a way that all the elements in it are traceable to the requirements.

9.2 EXAMPLE ALGORITHMS


1. Write the algorithm for finding the sum of any two numbers.

Solution Let the two numbers be A and B and let their sum be equal to C. Then, the desired algorithm is given as follows:
1. START
2. PRINT “ENTER TWO NUMBERS”
3. INPUT A, B
4. C = A + B
5. PRINT C
6. STOP

2. Write the algorithm for determining the remainder of a division operation where the dividend and divisor are both
integers.

Solution Let N and D be the dividend and divisor, respectively.


Assume Q to be the quotient, which is an integer, and R to be the remainder. The algorithm for the given problem is as follows.
1. START
2. PRINT “ENTER DIVIDEND”
3. INPUT N
4. PRINT “ENTER DIVISOR”
5. INPUT D
6. Q <- N/D (Integer division)
7. R <- N – Q * D
8. PRINT R
9. STOP

SVCE Page 29
UNIT 1 IT18101 PROGRAMMING FOR PROBLEM SOLVING

3. Write an algorithm that compares two numbers and prints either the message identifying the greater number or the
message stating that both numbers are equal.

Solution This example demonstrates how the process of selection or decision making is implemented in an algorithm using the
stepform. Here, two variables, A and B, are assumed to represent the two numbers that are being compared. The algorithm for this
problem is given as follows.

1. START
2. PRINT “ENTER TWO NUMBERS”
3. INPUT A, B
4. IF A > B THEN
PRINT “A IS GREATER THAN B”
5. IF B > A THEN
PRINT “B IS GREATER THAN A”
6. IF A = B THEN
PRINT “BOTH ARE EQUAL”
7. STOP

4. Write an algorithm to check whether a number given by the user is odd or even.

Solution Let the number to be checked be represented by N. The number N is divided by 2 to give an integer quotient, denoted
by Q. If the remainder, designated as R, is zero, N is even; otherwise N is odd. This logic has been applied in the following algorithm.

1. START
2. PRINT “ENTER THE NUMBER”
3. INPUT N
4. Q <- N/2 (Integer division)
5. R <- N – Q * 2
6. IF R = 0 THEN
PRINT “N IS EVEN”
7. IF R != 0 THEN
PRINT “N IS ODD”
8. STOP

5. Write an algorithm for the addition of N given numbers.

Solution Let the sum of N given numbers be represented by S. Each time a number is given as input, it is assigned to the
variable A. The algorithm using the loop construct ‘if … then goto …’ is used as follows:

1. START
2. PRINT “HOW MANY NUMBERS?”
3. INPUT N
4. S <- 0
5. C <- 1
6. PRINT “ENTER NUMBER”
7. INPUT A
8. S <- S + A
9. C <- C + 1
10. IF C <= N THEN GOTO 6
11. PRINT S
12. STOP

10 FLOWCHART

A flowchart comprises a set of various standard shaped boxes that are interconnected by flow lines. Flow lines
have arrows to indicate the direction of the flow of control between the boxes. The activity to be performed is
written within the boxes in English. In addition, there are connector symbols that are used to indicate that the
flow of control continues elsewhere, for example, the next page.

SVCE Page 30
UNIT 1 IT18101 PROGRAMMING FOR PROBLEM SOLVING

Guidelines for drawing a flowchart


Flowcharts are usually drawn using standard symbols; however, some special symbols can also be developed
when required. Some standard symbols frequently required for flowcharting many computer programs are
shown in the figure.

The following are some guidelines in flowcharting.


 In drawing a proper flowchart, all necessary requirements should be listed out in a logical order.
 There should be a logical start and stop to the flowchart.
 The flowchart should be clear, neat, and easy to follow.
 There should be no ambiguity in understanding the flowchart.
 The usual direction of the flow of a procedure or system is from left to right or top to bottom.
 Only one flow line should emerge from a process symbol.

 Only one flow line should enter a decision symbol, but two or three flow lines, one for each possible
answer, can leave the decision symbol.

 Only one flow line is used in conjunction with a terminal symbol.

SVCE Page 31
UNIT 1 IT18101 PROGRAMMING FOR PROBLEM SOLVING

 A sequence of steps or processes that are executed in a particular order is shown using process
symbols connected with flow lines. One flow line enters the first process while one flow line emerges
from the last process in the sequence.

 Selection of a process or step is depicted by the decision making and process symbols. Only one input
indicated by one incoming flow line and one output flowing out of this structure exists. The decision
symbol and the process symbols are connected by flow lines.

 Iteration or looping is depicted by a combination of process and decision symbols placed in proper
order. Here flow lines are used to connect the symbols and depict input and output to this structure.

SVCE Page 32
UNIT 1 IT18101 PROGRAMMING FOR PROBLEM SOLVING

10.1 EXAMPLE FLOWCHARTS

1. Draw a flowchart to find the largest of three numbers A, B,and C.


Solution

2. The XYZ Construction Company plans to give a 5% year-end bonus to each of its employees earning Rs 5,000 or
more per year, and a fixed bonus of Rs 250 to all other employees. Draw a flowchart and write the step-form
algorithm for printing the bonus of any employee.

SVCE Page 33
UNIT 1 IT18101 PROGRAMMING FOR PROBLEM SOLVING

3. Draw a flowchart for calculating the simple interest using the formula SI = (P * T * R)/100, where P denotes the
principal amount, T time, and R rate of interest.

SVCE Page 34

You might also like