Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
4 views33 pages

Computer Science Chapter Wise Short Notes Class 10

The document provides an overview of computer networks and telecommunications, detailing data communication, types of cables, wireless communication, network architectures, and protocols. It discusses advantages and disadvantages of different network types, including LAN, MAN, and WAN, as well as various topologies like bus, ring, and star. Additionally, it covers computer viruses, their transmission, symptoms, and antivirus solutions, emphasizing the importance of computer security.
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)
4 views33 pages

Computer Science Chapter Wise Short Notes Class 10

The document provides an overview of computer networks and telecommunications, detailing data communication, types of cables, wireless communication, network architectures, and protocols. It discusses advantages and disadvantages of different network types, including LAN, MAN, and WAN, as well as various topologies like bus, ring, and star. Additionally, it covers computer viruses, their transmission, symptoms, and antivirus solutions, emphasizing the importance of computer security.
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/ 33

Computer Network And Telecommunication

Data communication
The process of transferring data or information between computers called data
communication.
Telecommunication
It refer all types of data transmission like characters, numerical, photos, audios and
videos etc using electronic or light emitting media. Eg email, voice mail, yideo
conference etc
Cables (Guided Media)
Cables are the most common transmission media. Two or more devices are connected
directly using cables. Three types of cables are used in computer networking they are:
Twisted pair cable
Twisted copper cables are used only for lower bandwidth. It consists of two isolated
strands of copper wire twisted around each other. There are two types of twisted pair
cables they are as follows:
UTP (Unshielded Twisted Pair)
UTP cables does not have metal shield expect plastic coating. It contains number of
twisted pairs of wires with a simple plastic casing. It commonly used to for LAN and
Telephony. It is cheaper and easier to work with, but do not offer high bandwidth and
good protection from interferences. It can support data transmission rates from 10 to
100 mbps.
STP (Shielded Twisted Pair)
STP is similar to UTP but it is shielded with metal sheath along with plastic coating. It
offers high bandwidth and good protection from interferences. It is cheaper than fiber
optic cable. It can support data transmission rates from 10 to 500 mbps.
Co- axial cable
A co-axial carries higher bandwidth than twisted pair, it is easy to connect. It does not
bend readily. This cable consists of one or more small cables in a protective covering.
It offer very high data transfer rate and can be placed underground and laid on the
floors of lakes and oceans.
Fiber Optic cable
Fiber optic cable is a thin filament of glass fiver wrapped in a protective jacket. It
consists of strands of glass like thread, each about the diameter of a human hair. It
offer high-speed data transmission rate because data travel as high-speed pulses of
light.
Wireless (Unguided Media)
It is used to transfer data with in a large geographical areas or globally without the use
of interconnecting wires or cables. It uses other components such as radio signals,
microwaves, or infrared to connect network.
Types of wireless communication
Microwave System
Microwave signals are similar to radio and television signals and are used to transmit
data through the space without the use of cable. It provides high-speed data
transmission. These signals cannot bend or pass obstacles like hills and tall buildings,
so very high towers are used to mount the signals. The transmission is limited about
30 miles. Chain of towers is required to transmit the microwave signals in a long
distance
Satellite communication
Both microwaves signals and telephone signals can be relayed to a earth station for
transmission to a communication satellite. The earth station consists of a satellite dish
that functions as an antenna a communication equipment to transmit and receive data
from satellite passing overhead. It is not disturbed by hills and tall buildings and
visible from any point. So sender and receiver easily communicate with each other
using antenna by aiming the satellite. It is very expensive for placing satellite along
the earth orbit.
Modulation
The process of changing some characteristics (amplitude, frequency or phase) of
carrier wave in accordance with the intensity of the signal is known as modulation.
Types of modulation

 Amplitude Modulation (AM)


 Frequency Modulation (FM)
 Phase Modulation (PM)

Mode of communication
Simplex mode
Simplex is one-way data transmission that takes place only from sender to receiver.
An example of this would be a television that allows the signal to pass in only one
direction. Computer network connections do not use simplex.
Duplex mode
Duplex is two-way data transmission that takes place both directions over a
communication channel. Computer use duplex channel. For example if computer A
and computer B are connected together than both computer can share data or
information. From computer A to computer B or computer B to computer A.
Types of Duplex Mode
Half duplex
Half duplex is two way data transmission that takes place in only one direction at a
time. Eg walkie Talkie
Full duplex
Full duplex is two-way data transmission that takes place in both directions at a time.
Eg mobile communication, voice call, video-conferencing etc.
Computer Network
A computer network is a logical or physical interconnection between two or more
computers such that they could communicate with each other. It is used to provide
users with the access to share resources. These shared resources include data files,
application software and hardware.
Components of computer network.

 Computer
 Transmission media
 Network software.
 Protocols.
 Networking cables(Transmission media)

Advantages of computer network:

 Resources, data, software and hardware can be shared.


 Faster & cheaper communication and data transmission.
 It provides as the tools for e-mail teleconferencing videoconferencing which
facilities communication.
 Flexible working condition.
 Office automation can be making very effective well managed.

Disadvantages of computer network.

 High installation and administrative cost.


 Attack on the privacy of the people.
 Computer virus spread most easily through network.
 Technologically very complicated.
 If the server is out of order, then all workstations are hang up.
 Well trained technical support is required.

Network architectures or (Types of Network Architecture) or LAN Architecture:


Client server Network Architecture
This is old model of computer network. In this kind of network model one main
computer equipped with very powerful processor, large memory and network
operating system works as a main computer or service provider. Other computers
connected with server, which are also called workstation or node or terminals can use
the hardware and software resources of server computer. There are different types of
server such as file server, print server, network server or email server.
Advantages of client server network:

 It works with any size or physical layout of LAN.


 It does not tend to slow down with heavy use.
 The network can be expanded to any size as we wish.
 It provide very high level security
 It reduces software installation time and cost to all computers.

Disadvantages of client server network:

 It is very difficult to setup and well trained technicians are required to handle
and setup.
 It is expensive compare to peer to peer network.
 All software and operating systems are installed in server computer so that
other client computer has to depend on it.

Peer to peer Network Model


It is also called workgroups also. Because all computers in the network have equal
responsibilities. All computers in the network have access to at least on e or more
computers. It mostly used in LAN and every organizations, research centers such as
banks, travel agencies, airlines educational institutions etc.
Advantages of peer to peer network:

 It is easy to setup.
 Users in each computer can determine the resources to be shared among other
computers.
 Any required software can be installed on individual computers , they don‟t
have to depend on the server.
 It is suitable at home, office, banks and small organization.
 It is cheaper compare to client server network.

Disadvantages of peer to peer network:

 It is slow because of heavy load.


 It is suitable for limited area such as school offices and small organization.
 The network expansion is limited and can not be expanded as the wish.
 It has limited security level.

Types of computer network on the basis of geographical area


Local Area Network(LAN)
The way of connecting two or more computers in a very limited area (about 100 to
300 meters) or within a same building or a group of adjacent building is called LAN.
It enables very high speed communication through wire connection or wireless
connection some times. Small organizations prefer it because of less expensive and
faster communication.
Metropolitan Area Network(MAN)
The way of connecting computers inside a metropolitan area is called MAN. The area
may be a part of city, whole part of city, district, zone or country. Radio wave is used
to transmit the data for communication between the workstation and server in the
system. Many different systems of networking and computing are brought together to
form a MAN.
Wide Area Network(Wide Area Network)
The connection of computers of networks covering more distance or the world by the
help of wave, frequency and satellite is called WAN or Internet. Different types of
LAN and MAN are connected to form a WAN. It covers more area but it is slower
than LAN and MAN.
Network Topology
The physical structure of network is called topology. It may contain software,
hardware or geographical situation of the networking. Or in another words it is the
pattern in which the computers are interconnected.
Types of Network Topology
BUS Topology
Uses a single length of cable to interconnect network devices. Uses terminators to
dampen signal reflection at the ends of the cables
Advantages of Bus topology

 Since each small segments of cables are joined to form a trunk or network bus
it is easy to setup computers on the bus.
 Since nodes are arranged in the linear form, it requires the less amount of
cables.
 The coaxial cables used for networking are inexpensive and joining connectors
on the cables is also easy.
 The position of server computer can be any where on the bus topology.
 Failure of any node does not affect other nodes on the network. f. Well suited
for temporary networks (quick setup)
Disadvantages of Bus topology

 If the backbone cable i.e. network bus has problem then the entire network
fails.
 Finding fault on this topology is not easy.
 It provides limited flexibility for change, so adding or removing nodes in
between is not easy.
 The performance degrades when the number of computers is more on the
network. So, it is not suitable for big size network.

Ring Topology:
Devices are connected in a ring formation. It support very high data transmission rate
Advantages of Ring Topology

 Since each node on the ring acts as a repeater, no any external repeater is
required to boost up the signals.
 It supports high data transmission rate.
 It is easy to setup.

Disadvantages of Ring Topology

 If any node or connecting cable fails the entire network does not work.
 The diagnosis of the fault is difficult.
 Since data or message reaches on the node in sequence, so addition of new
nodes increases the communication delays.
 It provides limited flexibility for change, so adding or removing nodes in
between is not easy.

Star Topology:
Most commonly implemented network topology used today that uses centrally located
device i.e hub or switch is known as Star Topology.
Advantages of star network

 Computers can be added or removed easily without affecting the network.


 If any of the workstation or the connecting cable fails, it does not affect the
remaining portion of the network.
 Fault detection in the star topology is easy.
 It is easy to extend so it is suitable for a large network.
 It is one of the most reliable network topology.

Disadvantage of Star Topology


 Since each node is required to connect with the centralized hub or switch more
cables are needed which increases the cost of installation.
 The entire network fails if there is any problem on the hub or switch.
 In comparison to Linear and Ring topologies, t is little expensive as it requires
more length of cables and other controlling devices.

Different devices and terms used in Network:


MODEM
Modem is a device that directly converts digital signal from a computer or other
digital devices into analog form for transmission over analog link i.e telephone line
and vice versa. MODEM stands for Modulation and Demodulation. There are two
types of modem used in computer they are as follows:
Internal modem and External modem.
NIC
It is a Network Interface Card, which connects each computer to the wiring to the
network. A NIC is a circuit board that fits in one of the computer‟s expansion slots. It
provides a port on the back of the computer to connect in the network.
Hub
Hubs are connectivity devices, which contain multiple ports for connecting to network
components. Hubs connect the computers in a star topology. It lies between server and
clients computers.
Connector : Bridge and Gateway are the two different connectors, which play role to
link between two network systems.
Bridge
Bridge connects networks using same communications protocols or similar networks
so that information can be passed from one to the other.
Gateway
Gateway connects networks using different communications protocols or dissimilar
networks so that information can be passed from one to the other.
Switch
A device that capable of forwarding packets directly to the ports associated with
particular network addresses. Hubs and switches are almost same but switch is new
technology and intelligent compare to hub.
Repeater
A device used on communications circuits that decrees distortion by amplifying or
regenerating a signals so that it can be transmitted onward in its original strength and
form as they pass through a network cable.
Protocols
Protocols are the set of rules and formats for sending and receiving data. It works as
guidelines to govern the exchange between equipments. There are different types of
protocols that we can use. Some of popular protocols are TCP/IP, HTTP, FTP,
IPX/SPX.
Router
A router is a device that is used to connect different LAN in the network. It receives
transmitted messages and forwards them their correct destinations over most efficient
available route.
NOS(Network Operating System)
The operating, which can support network environment, is called Network Operating
System. For example Windows XP, 2000, server, unix, linux, Novel Netware etc.
Network Protocol(Communication Protocol)
A set of rules by which computers on the network communicate with each other is
known as network protocol. The common protocols used on the network are:
TCP/IP (Transmission Control Protocol / Internet Protocol)
SMTP (Simple Mail Transfer Protocol)
FTP (File Transfer Protocol)
HTTP (HyperText Transfer Protocol)
POP (Post Office Protocol)
IPX/SPX (Internet Packet Exchange/Sequential Packet Exchange)
NetBEUI (NetBIOS Extended user interface)
AppleTalk
VOIP(Voice Over Internet Protocol)
HTTPs (HyperText Transfer Protocol Secured)
UDP(User Datagram Protocol)
Internet and its Services
The Internet is the interconnection of millions of computers across word wide in order
to share data and information. It is the largest network formed by connecting
computers on LANs, MANs and WANs of the whole world through the TCP/IP
protocol to share data and information.

The services provided by the Internet to the client computers are WWW, E-mail,
Chat , E-Fax, Video Conference, E-commerce , File transferring , Telnet,
Newsgroup, tele-medicine, social network service, e-learning and so on.
The components required to use internet in a computer are Web Browser , Internet
Account (ISP), Router, telephone line, cable internet line, optical fiber etc. A web
browser is the essential software required for browsing or surfing web sites on the
internet.Google Chrome, Netscape Navigator, Microsoft Internet Explorer and
Mozilla FireFox are the popular web browsers. An ISP (Internet Service Provider)
provides facility of the internet to the users. The local ISP connects a computer to the
internet. World Link, ADSL, Vianet, Web Surfer, Otel, Subisu are the popular local
ISPs of Nepal.
Intranet : It is a private network owned by a company or an organization with limited
users, limited services and limited area to share data and information.
Computer Virus
Computer virus is a malicious, destructive and self-replicating computer program that
disrupts the normal functioning of the computer system. Computer viruses can
transfer from one computer to another through different sources to a computer without
the knowledge and permission of the user and they are capable for hiding themselves
in other files.

Route of transmissions of Computer Virus are


Sharing of infected external portable hard disk, pen drive or CDs and DVDs.
Using pirated software (Illegal software).
Opening of virus infected e-mail messages and attached file.
By downloading files or programs from the web sites which are not secured.
By exchanging of data, information or files over a network.
Browsing untrusted sites.
Symptoms of Computer Virus
Programs take more time to load, fail to load or hang frequently.
Unexpected messages or images appear suddenly on the screen.
Missing of files or appearing of unexpected files.
Displays unusual error messages or encounters errors frequently.
Displays low memory message frequently.
Programs open automatically without giving instruction.
Types of Computer Viruses
Boot Sector Infector Virus
File Infector or Parasitic Virus
Multipartite Virus (Both features of Boot Sector and File Infector virus)
Macro Virus
Script Virus
Anti-Virus
Antivirus is a constructive program that detects and eliminates viruses from computer.
Some popular antivirus are Kaspersky Anti-virus, Avira Antivirus, Norton Antivirus
(NAV) , McAfee Antivirus, Panda Anti-Virus, AVG Anti-Virus etc.
Computer Security
The securing computer data, information, software and hardware from being damaged
or lost due to accidental or intentional is known as Computer Security.
Types of Computer Security
1. Hardware Security Measures

 Regular Maintenance
 Insurance
 Free from dust environment
 Protection from fire
 Protection from theft
 Using Air condition system
 Using Power Protection devices (UPS, Spike guard, CVT, Voltage Stabilizer)

2. Software Security Measures

 Using Password Policy


 Using Antivirus Software
 Using Backup
 Scandisk utility
 Defragmentation
Cyber Law and Computer Ethics
The cyber law is formulated in order to legalize the electronic transaction through
electronic media, to control the various types of electronic frauds , to punish a person
who does criminal activities through electronic means especially computer, to
promote e-commerce and e-governance.

Cyber Law of Nepal


Cyber Law of Nepal was introduced on 30th Bhadra, 2061 (15 September, 2004) in
order to legalize the electronic transaction and to control cybercrimes.
Computer Ethics
It is a code of conduct or set of rules and regulation that should be followed by each
and every computer users while using computer or electronic media i.e Internet.
Computer Ethics are
We should not use a computer to harm other people.
We should not use or destroy other‟s files or database.
We should not use computer to publish fake information.
We should not copy or make duplicate copy and distribute illegally.
We should not steal computer password of others or use it.
We should not use other people‟s computer resources without permission.
We should not steal or use digital signature and pin of ATM card of others.
We should not create a virus and use it.
We should not publics an illegal pictures or videos in electronic form.
Multimedia and its Applications
Multimedia is technology for presenting the information in more attractive,
interesting, interactive and understandable manner with the help of different media
like text, pictures, videos, sounds, and animations.
Components of Multimedia

 Text
 Audio
 Video
 Animation
 Sound

Application of Multimedia Technology

 Multimedia in education
 Multimedia in Business
 Multimedia in Internet
 Multimedia in Animated movies
 Multimedia in Video games
 Multimedia in industries

Advantages of Multimedia

 It is used to present ideas, information to others in effective ways.


 It is used in smart class for teaching different subjects in interesting, and
effective ways.
 Student can learn, read and test his/her knowledge using multimedia
technology.
 It is used in animated Games and movies to make more realistic.
 It is used in Electronic advertising to present the information.

Disadvantages of Multimedia

 The cost of developing a multimedia product is high.


 An ordinary computer doesn‟t support multimedia.
 The Skill manpower is required to operate multimedia.
 It is an expensive technology
Database and DBMS (MS-ACCESS)
Data: It is the collection of facts and figures collected from different like
questionaries‟ and queries. Data are information to the computer which are processed
to get desired result and are the piece of information.

Information: The data which gives meaning or suitably arranged for communicating
interpretation, and processed by human being by automated means such as computer
is called information.
Database
A database is a collection of data that is organized so that its contents can easily be
accessed, managed and updated. Examples of database system are
Banking software
Airlines systems
University systems
Telecommunication systems
Finance
Sales
Manufacturing
Human resources
File
A file is a collection of electronic information store in computer.
Record: A record is a information about an element such as a person, animal, students,
place etc.
DBMS
A database management system (DBMS) is a computer program designed to manage
a database (a large set of data), and run operations on the data requested by clients.
For example Oracle, Microsoft Access, Ms. SQl, MySQl, dBASE, dBase,
FoxPro, SYSBASE etc. are the well-known database management system.
RDBMS
Relational Database Management System (RDBMS) is method of viewing
information from several, separate database that relate to one another through the
keyword or values. The main advantage of RDBMS is that we can simultaneously use
more than one database to see information stored in them.
Importance of database:

 Database stores the data.


 Computerized database saves data from being lost.
 Computerized database protects from unauthorized access and use of the data.
 Data can be stored in a small area or space in computerized database.
Features of DBMS:

 Easy to access data.


 Ease to modify data.
 Delete existing data.
 Organize the data in proper sequence.
 Sorting and indexing of data.
 Easy queries in data.
 Retrieve the data easily.
 Print the formatted reports, labels etc.
 Linking between two or more databases.
 It can be used as SQl (Structured Query Language)

Microsoft Access
It is a RDBMS software.
Features of Microsoft Access:

 It provides very useful database features such as tables, forms, reports and
queries.
 It works as front end development tool.
 This provides end-user applications developer environment.
 It shares data with other application such as Microsoft Word or Excel.
 It support three computer programming language such as: SQL, Macros and
Visual BASIC etc.

Objects of MS Access
Table
A table is collection of data about a specific topic, such as products or suppliers.
Using a separate table for each topic means that you store that data only once, which
makes your database more efficient, and reduces data entry errors.
Table is the primary object of Ms Access. A table stores data in tabular form. A table
is made up of rows and columns.
Some parts of table are as follows:
Fields (column): The title name of the column that holds data is known as field. A
table can have many fields.
Records (rows): The collection of data horizontally for each field is known as record.
A record is complete information about an entity.
Data: The actual information stored under a filed title in a row is called data.
Index: A table can have index attached with it. The index is used to keep the data in
organized for and helps faster retrieval of data.
Primary key: A primary key is a field which is uniquely identified. All the records of a
table are uniquely identified on the basis of primary key. The column that has been
defined as the primary key can‟t hold null value. For example a student‟s roll no. can
be defined as primary i.e can‟t be null and repeat.
Compound key: The primary key based on more than one field is known as composite
key. It consists of multiple columns, because one column is not sufficiently unique.
Foreign key: Foreign key is the linking pin between two tables. It shows the relation
between any two tables.
Queries
A query is an object of MS-Access which is used to retrieve records from
database,search or question that you make for a record or item. The record is stored in
the database file. Queries help to investigate about data records.
Forms
Forms present the data from a table or a query in a way we want it to be displayed.
The fields in the table or query are made available to place on the forms we create.
Uses of form.

 Displaying and editing data.


 Controlling application flow.
 Accepting input.
 Displaying messages.
 Printing information.

Reports
Reports are the printed results of data processing. Reports are specially formatted
collections of data, organized according to your specification for summarizing and
printing listings of database data. While forms are designed to be used onscreen,
reports are designed to be viewed and printed.
Relationship: In a database we can establish relation between any two or more tables.
Because no data are isolated, but they are associated or related with each other entity
in one or another ways. we can generate reports and manipulate data using such
relationship between tables.
Data Type of Ms Access
Data type defines the nature of the data to be stored in the column. Access provided
different types if data that can be stored.

 Text : (Default) Text or combination of text and numbers, up to 255 characters.


 Memo : Use for lengthy text and numbers, such as notes or descriptions. Stores
up to 65,536 characters.
 Number: Use for data to be included in mathematical calculations.
 Date/Time: Use for dates and times . It occupies 8 Bytes.
 AutoNumber :Use for unique sequential (incrementing by 1) or random
numbers that are automatically inserted when a record is added.
 Yes/No :Use for data that can be only one of two possible values, such as
Yes/No, True/False, On/Off. Null values are not allowed.
 OLE Object :Use for OLE objects (such as Microsoft Word documents,
Microsoft Excel spreadsheets, pictures, sounds, videos or other binary data)
that were created in other programs using the OLE protocol.
 Hyperlink : Text or combination of text and numbers stored as a text and used
as a hyperlink.
 Lookup Wizard Use to create a field that allows you to choose a value from
another table or from a list of values using a combo box— -choosing this
option in the data type list starts a wizard to define this for you.
 Currency : To store monetary value. It occupies 8 Bytes memory.

Field Properties:

 Format: It allows choosing different format of data type available.


 Caption: It used to display alternative name for the field to make the field name
more explanatory. It can contain up to 2,048 characters.
 Default Value: Default value is the one that enter automatically in the database
and can be changed as per required.
 Validation Rule: It is used to set the limitation while entering data in the
database. It helps us to customize the data entry and checks for error entry of
data.
 Validation Text: If wrong data is entered which do not supported by given
validation rule, it is used to display messages on the screen and work as a
precaution of wrong data entry.
 Required: If required is set as Yes then field should always receive a value
during data entry.
 Indexed: You can choose whether you want to index the table. The available
index options are unique index and duplicate index.
 Input Mask: It is usually used to set control the data entry in the database.
Using this option we can customize the data entry by setting special commands
using the following symbols:
 Field size property is set to the maximum size for data stored in the field set to
the text or number data type. For next data, the default field size is 50 and
maximum size is depending on the type of data types.

Data Sorting
The process of arranging the data of table either in ascending or descending order is
known as data sorting.
Review of Control Statements in QBASIC
IF Statements in QBASIC
1.IF …. THEN Statement
IF THEN Statement
Or,
IF THEN
Block of statements
END IF
Where, condition is a logical expression that evaluates either true or false.
2. IF….. THEN….. ELSE Statement
Syntax:
IF THEN
Statement1
ELSE
Statement2
END IF
3. IF….. THEN….. ELSEIF….. ELSE Statement
Sytanx:
IF THEN
Statement1
ELSEIF THEN
Statement2
ELSEIF THEN
Statement3
…….
……….
………
……….
ELSE
Statement_N
END IF

REM find the greatest number among any 10 numbers.


CLS
FOR j=1 TO 10
INPUT “Enter a number”;n
IF n>g THEN g=n
END IF
PRINT “The largest number is “; g
END
REM finds the middle number among any three numbers.
CLS
INPUT “Enter any three numbers”; a, b, c
IF (a>b AND ac) THEN
PRINT a; “ is the middle number.”
IF (b>c AND ba) THEN
PRINT b; “ is the middle number.”
ELSEIF (c>a AND cb) THEN
PRINT c; “is the middle number.”
END IF
END
SELECT CASE Statement
Syntax:
SELECT CASE testexpression
CASE expressionlist-1
[Statements Block-1]
[CASE expressionlist-2
[Statements Block-2]]
………
……….
………
……….
[CASE ELSE
[Statements Block-N]]
END SELECT
REM counts total number of vowels and consonants in a word.
CLS
INPUT “Enter a word“; W$
R$= UCASE$(W$)
FOR K= 1 TO LEN(R$)
E$= MID$(R$, K, 1)
SELECT CASE E$
CASE “A”, “E”, “I”, “O”, “U”
x=x+1
CASE ELSE
y=y+1
END SELECT
NEXT K
PRINT “The number of vowels in the word :”;x
PRINT “The number of consonants in the word:”; y
END
Loops in QBASIC
The repetition of the statement block time and again till the condition is satisfied is
known as loop. The looping statements supported by QBASIC program are
1. For Next Loop
Syntax:
FOR Variable = start TO end STEP (increment/decrement)
[Block of statements]
NEXT Variable
REM displays first 10 even numbers and sum of those even numbers.
CLS
N=2
FOR P = 1 TO 10
PRINT N;
S=S+ N
N=N+2
NEXT P
PRINT “Sum of the first ten even numbers:”;S
END
2. WHILE …. WEND Loop
Syntax:
WHILE
[Statements block]
WEND
3. DO…LOOP
Syntax-I (Entry Control Loop Structure):
DO WHILE|UNTIL
[Statements block]
LOOP
Syntax-II (Exit Control Loop Structure):
DO
[Statements block]
LOOP WHILE|UNTIL
Where, Condition is the logical expression that evaluates as true or false.
REM Sum of digits of an integer
CLS
INPUT “Enter an integer”; N
DO
R = N MOD 10
S =S+ R
N=INT(N/10)
LOOP WHILE N<>0
PRINT “Sum of digits”; S
END
REM Sum of digits of an integer
CLS
INPUT “Enter an integer”; N
DO
R = N MOD 10
S =S+ R
N=INT(N/10)
LOOP UNTIL N=0
PRINT “Sum of digits”; S
END
Nested Loop
The loop inside a loop is called nested loop.
Syntax:
FOR Variable1 = start TO final STEP (Increment or Decrement)
FOR Variable2 = start TO final STEP (Increment or Decrement)
[Statements block]
NEXT Variable2
NEXT Variable1
CLS
FOR j= 1 TO 5
FOR k = 1 TO j
PRINT k;
NEXT k
PRINT
NEXT j
END
Review of Library Function
A function in QBASIC is a readymade small program or user made small program
that can perform a specific task. The function manipulates the data passes to it and
returns either a string or a numeric value. QBASIC supports two different kinds of
functions.
i. User Defined Function
ii. Library Function
User Defined function is created by a user using function procedure to perform certain
task which can‟t perform by using library functions.
Library function is also known as Built-In function or Routine function. A library
function in QBASIC may be string function or numeric function. A string library
function can manipulate either string or numeric data and returns a string value. A
function name having dollar sign ($) is string function. LEFT$(), Right$(), CHR$(),
STR$( ), UCASE$( ), DATE$ ( ), MID$(), DATE$(), TIME$(), SPACE$(),
LTRIM$(), RTRIM$(), INPUT$(), etc. are some example string functions. A
numeric function can manipulate either string or numeric data and returns a numeric
value. A numeric library function name has no type declaration sign. CINT(), SQR(),
ASC(), VAL(), LEN (), SGN( ),ABS( ), SIN( ), TAN( ), COS() etc. are some example
of numeric library functions.
REM converts uppercase letters of a word in lowercase and vice versa.
CLS
INPUT “Enter a word”; W$
FOR k = 1 TO LEN (W$)
E$= MID$(W$, k, 1)
IF E$=UCASE$(E$) THEN
New$ =New$+ LCASE$(E$)
ELSE
New$ =New$+ UCASE$(E$)
END IF
NEXT k
PRINT “New word after converting case is :”; New$
END
REM removes vowels characters from the supplied word.
CLS INPUT “Enter a word:”; W$
FOR j= 1 TO LEN(W$)
E$= UCASE$(MID$(W$, j, 1)
IF E$<>”A” AND E$<>”E” AND E$<>”I” AND E$<>”O” AND E$<>”U”
THEN
New$=New$+E$
END IF
NEXT j
PRINT “New word is :”; New$
END
REM to check palindrome word.
CLS
INPUT “Enter a word”; W$
FOR j= LEN (W$) TO 1 STEP-1
rev$= rev$+MID$(W$, j, 1)
NEXT P
IF W$=rev$ THEN
PRINT “Palindrome word”
ELSE
PRINT “Not palindrome word”
END IF
END
REM converts Decimal number into Binary Number.
CLS
INPUT “Enter a Decimal number”; N
M=N
DO WHILE N<> 0
R= N MOD 2
B$=STR$(R) + B$
N= INT(N/2)
LOOP
Ans=VAL(B$)
PRINT “Binary equivalent of entered number is “; Ans
END
Modular Programming in QBASIC
The programming technique, in which a large and complex program is divided into
small logical and manageable part of the program which can perform specific task, is
known as modular programming. The small, logical and manageable part of the
program is called procedure (module). Since the modular programming uses small
block of functional codes, it is also called structured program.
Advantages of modular programming

 A procedure can be reused in a program which reduces the length of the


program.
 It is suitable for a team work so that task can be divided with a team members.
 The debugging of the program becomes easier and faster since they are divided
into different modules.
 The procedure can be tested and debugged separately.
 The documentation of an individual procedure is simpler as compared to the
documentation of a large and complex program.

Types of procedure
1. Sub Procedure
A Sub procedure is a small, logical and manageable functional part of a program
which performs the specific tasks and does not return any value to the main module. A
sub procedure can call another sub procedure in the program. A sub procedure is
called by using CALL statement. When a sub procedure is called the program control
transfers from the main module to the sub module and the execution of the codes in
the sub module takes place. After the completion of execution of its codes the
program control returns to the next statement of the calling module i.e. after the
CALL statement.
2. Function procedure
A Function procedure is a small, logical and functional part of a program which
performs the specific tasks and it returns a single value to the main module or calling
module. The returned value of the function procedure may be string or number. So,
there are two types of user defined functions. They are String Function and Numeric
Function. Once the function procedures are defined in the program they can be used in
the program. To use the function procedures in a program, the procedure needs to be
called from the main module. The PRINT Statement or a variable is used to call the
function procedure.
REM to display volume of cylinder
DECLARE SUB Volume ( r, h)
CLS
CONST pi=22/7
INPUT “Enter radius of a cylinder”; r
INPUT “Enter height of the cylinder”;h
CALL Volume (r, h)
END
SUB Volume (r, h)
v = pi*r^2*h
PRINT “Volume of the cylinder =”; v
END SUB
REM checks whether input integer is prime or composite.
DECLARE FUCNTION PRIME$(N)
INTPUT “Enter an integer”; N
PRINT “The number is :” PRIME$(N)
END
FUNCTION PRIME$(N)
FOR P= 1 TO N
IF N MOD P = 0 THEN C= C + 1
NEXT P
IF C=2 THEN
PRIME$= “Prime”
ELSE
PRIME$=”Composite”
END IF
END FUNCTION

REM to display longest student name among any ten names


DECLARE FUNCTION Longest$(n$( ))
CLS
DIM n$(10)
FOR P= 1 TO 10
INPUT “Enter student name”;n$(P)
NEXT P
PRINT “The longest student name is “; Longest$(n$( ) )
END
Function Longest$(n$())
long$= n$(1)
FOR P = 2 TO 10
IF LEN (n$(P))>LEN (l$) THEN long$= n$(P)
NEXT P
Longest$= long$
END FUNCTION
REM to display the number in an ascending order using an array with sub procedure.
DECLARE SUB SORT ( N( ) )
CLS
DIM N(10)
PRINT “Enter ten different numbers:”
FOR P= 1 TO 10
INPUT N (P)
NEX P
CALL SORT (N ( ))
END
SUB SORT (N ( ))
FOR P= 1 TO 9
FOR Q = 1 TO 10-P
IF N (Q)>N (Q+1) THEN SWAP N (Q), N (Q+1)
NEXT Q
NEXT P
PRINT “Numbers are in ascending order:”
FOR P = 1 TO 10
PRINT N (P)
NEXT P
END SUB
REM uses of global variable
DECLARE SUB Average ( )
COMMON SHARED a,b,c
CLS
INPUT “Enter three numbers “; a,b,c
CALL Average
END
SUB Average
Avg=(a+b+c)/3
PRINT “average= “;Avg
END SUB
Note: In the above program a,b,c are global variables and Avg is a local variable.
File handling in QBASIC
Program file
A program file has a set of instructions and codes which are needed for data
processing. It has .BAS as an extension.
Data file
A data file has collection of related data stored in a secondary storage device of
computer. Such a collection of data in a row is known as a record. A record in a data
file contains the detailed information of a person or anything. For example, a record of
a data file related to „employee‟ consists of employee name, post, department, date of
birth and salary. A field is a particular data of a record.
Types of data file
1. Sequential Access File
Sequential access file, data is stored in sequential order. The data of a sequential
access file can only be accessed sequentially. For example, if a sequential access data
file has stored name of a person, address and age of some people then data of this file
need to access in the same order as the data are stored in a row. Since the accessing of
data from the sequential data file is done in sequential order, the accessing data takes
long time if the data file contains large records.
2. Random access data file
A random access file allows us to write or read data from any location of the file. We
can read or write any record directly in a random file without searching through all the
records that precede it. Thus, reading and writing of data is faster than sequential
access data file.
How to open a sequential data file?
OPEN statement is used to open a sequential data file.
Syntax 1: OPEN FOR AS # Filenumber
Where,
Filename is the name of the sequential data file.
Mode determines the operation of data file like OUTPUT, INPUT and APPEND. The
different modes and their purposes are listed below.
OUTPUT mode
To create a new sequential data file and store data in it.
INPUT mode
To retrieve the contents of the existing data file.
APPEND mode
To add more records in the existing data file.
File number is a number from 1 to 255 that identifies the data file.
REM to create a new sequential data file and to store data.
CLS
OPEN “employee.dat” FOR OUTPUT AS # 1
DO
INPUT “Enter employee name “;n$
INPUT “Enter address”; a$
INPUT “Enter post”;p$
INPUT “Enter salary”; sal
WRITE#1, n$,a$,p$,sal
INPUT “Do you need more records (y/n)”; ch$
LOOP WHILE UCASE$(ch$) = “Y”
CLOSE#1
END
REM to display the content of datafile
CLS
OPEN “employee.dat” FOR INPUT AS # 1
PRINT “Name”, “Address”, “Post”, “Salary”
WHILE NOT EOF (1)
INPUT#1, n$,a$,p$,sal
PRINT n$,a$,p$,sal
WEND
CLOSE#1
END

REM add more records to the data file


CLS
OPEN “employee.dat” FOR APPEND AS # 1
DO
INPUT “Enter employee name “;n$
INPUT “Enter address”; a$
INPUT “Enter post”;p$
INPUT “Enter salary”; sal
WRITE#1, n$,a$,p$,sal
INPUT “Do you need more records (y/n)”; ch$
LOOP WHILE UCASE$(ch$) = “Y”
CLOSE#1
END
An introduction to C Language
C is a high level programming language developed at AT & T‟s (American Telegraph
and Telephone) Bell Laboratories of USA in 1972. It was designed and written by a
man named Dennis Ritchie. In the late seventies C began to replace the more familiar
languages of that time like PL/I, ALGOL. It is general purpose high level
programming language, which is used to develop business programs, text processing
programs, database management programs and even to develop Operating System
(OS). It is also known as structured programming language.
Structured Programming is a programming methodology that produces programs with
clean flow, clear design, and a degree of modularity or hierarchical structure. Benefits
of structured programming include ease of maintenance and ease of readability by
other programmers.
Advantages of structured programming language

 A large and complex program can be divided into several simpler and
manageable sub modules.
 Support simultaneously coding of modules by multiple programmers at a time.
 Modules and functions once built here can be used in other programs.
 It reduced testing and debugging time.
 The program can be easily modified.
 It is portable and occupies less memory space in computer.

Features/Characteristics of C language

 It is structured programming language.


 It is general purpose programming language.
 It contains rich and powerful set of operators.
 It contains rich and powerful set of declaration and data types.
 It allows manipulation of internal process registers.
 It is a middle level programming language that supports both high and low
level programming languages. So, it is used to develop system software and
application software.

Similarities in QBASIC and C language

 Both languages can be used to develop structured programs.


 Both languages support local and global variables.
 Both languages support procedures.

Differences between QBASIC and C language


 QBASIC is high level language whereas C language is a middle level language.
 QBASIC supports both sub procedure and function procedure whereas C
language supports only function procedure.
 QBASIC is basically used for developing application software whereas C
language is used to develop system software and application software.

Basic elements of C language are listed below


i. C Language character set
The C character set is a set of characters which are allowed to represent information in
C language. The C character set consists of the alphabets (both upper case and lower
case), the digits (0-9) and certain special symbols (+ - * & ^ % $ # @ ! ? > < etc ).
ii. Identifiers in C Language
In a C program every word is either classified as an identifier or a keyword. Identifiers
are used to identify or name various program-elements such as variables, symbolic
constants, functions, etc.
iii. keywords in C Language
Keywords are reserved words which have special meaning for the C compiler.
Keywords are not allowed to use as identifiers. Keywords are also known as reserved
words. There are 32 keywords in C. The keywords of C language are auto, double, int,
struct, break, else, long, switch, case, enum, register, typedef, char, extern, return,
union, const, float, short, unsigned, continue, for, signed, void, default, goto, sizeof,
volatile, do, if, static, while.
iv. Data type in C Language
The data type in C language defines the amount of storage allocated to variables and
the values that variables can accept. C language supports basic four data types. They
are char, int, float and double.
The space occupies by int is 2 bytes, char is 1 byte, float is 4 bytes and double is 8
bytes.
Data type modifier
The keyword that modifies the size and range of the basic data types is known as Data
Type Modifier. The modifiers define the amount of storage allocated to the variable.
The C language uses four types of data type modifiers. They are signed, unsigned,
long and short. The data type modifier changes the size and range of the data that can
be stored in a variable.
v. Variables in C Language
In C language, you need to declare variables before you use them in a program. A
variable declaration tells the compiler the name and type of a variable. If a program
attempts to use a variable that has not been declared, the compiler generates an error
message.
In C language to store a character, a Character variable is used, to store string, an
array variable is used and to store numeric values, numeric variables like integer
variables and floating point variables are used.
vi. Operators in C Language
An operator is a symbol that operates on a certain data type and manipulates them to
produce the output. The operators used in C are listed below.
Arithmetic Operator
The arithmetic operator performs arithmetic operation on two operands. The
following arithmetic operators are used in C +, -, /, *, % .
Unary Operators
A unary operator is an operator, which operates on one operand. The commonly used
unary operators are increment (+ +) and decrement (- -) operators. The ++ operator
increments the value of the variable by one, whereas the - - operator decrements the
value of the variable by one. For example, x ++ is equivalent to x = x + 1 and x- - is
equivalent to x = x-1.
Relational Operators
Relational operators compare two expressions and return result in term of True or
False. The following relational operators are used in C language.
operators meaning expression <, <= , >= ,= = , ! = ,>
Logical Operators
A logical operator is used to combine relational expressions and returns the result
either in True or False. The logical operators used in the C language are given below.
&&, ||, !.
Assignment Operator
An assignment operator (=) is used to assign a constant or a value of one variable to
another.
Conditional Operator
A conditional operator checks for an expression, which returns either a true or a false
value.
Header files in C Language
A header file is a standard file that contains definitions of variables and functions
necessary for the functioning of a program. A header file is included in a program by
using „#include‟ directive. The header files in C language have .h extension. Some
header files are listed below.
i. stdio.h
This is the standard input output header file that provides functions for performing
input and output operations. It contains the declarations of I/O functions like printf ( ),
scanf( ), putchar(), getchar() etc.
ii. string.h
The string header file provides many functions useful for manipulating strings which
contains the declarations of library functions like strrev(), strlwr(), strupr(), strchr ( ),
strcmp( ), strlenr( ),etc.
iii. math.h
The math.h file is standard header file that handles mathematical functions like sqrt(),
pow(), etc.
iv. ctype.h
The ctype.h header file contains declarations for character classification functions like
isspace(), isupper(), tolower() etc.
Some C Language programs are given below
/* this program displays the product of two numbers*/
#include<stdio.h>
#include<conio.h>
void main()
{
int a, b, p;
clrscr();
a = 20;
b =16;
p= (a * b);
printf(“product of two numbers is %d”, p);
getch();
}
/* to check whether an input number is even or odd */
#include<stdio.h>
#include<conio.h>
void main()
{
int n, r;
clrscr();
printf(“Enter an integer”);
scanf(“%d”,&n);
r = n% 2;
if(r==0)
printf (“%d is even number”,n);
else
printf(“%d is odd number”,n);
getch();
}

You might also like