Plus One Computer Science Notes by ACT Malappurm - Eng Med
Plus One Computer Science Notes by ACT Malappurm - Eng Med
MALAPPURAM
COMPUTER SCIENCE
CLASS XI
Prepared by:
5 Introduction to programming 25
7 Control Statements 33
8 Arrays 37
10 Functions 44
11 Computer networks 48
ACT MLPM 2
CHAPTER 1
The discipline of Computing
ACT MLPM 3
• Developed by Charles Babbage
• compile mathematical tables, do ar i t h m e t i c a l o p e r a t i o n s a n d p r i n t r e s u l t s
automatically
7. Analytical Engine
• Developed by Charles Babbage in 1833
• Had many essential features found in modern digital computer.
• Programmable using punched cards
• It had a store(memory) and a separate ‘Mill ’(Processor )
8. Hollerith's machine:
• H e r m a n H o l l a r i t h m a d e fi r s t electromechanical punched card tabulator with input,
output and instructions.
• Use d ele ctricity to re a d , coun t an d sort p unc he d cards .
9. Mark-I Computer:
• Developed by Howard Aiken
• Could do all 4 arithmetic operations,logarithmic and trigonometric functions.
Generations of Computer
1) First generation computers:
• Used Vacuum tubes
• The ENIAC (Electronic Numerical Integrator and Calculator ), the
first general purpose programmable electronic computer(built by J. P. Eckert and John Mauchly.)
• UNIVAC( UNIVersal Automatic Computer ). - first commercially successful computer
• Von Neumann designed EDVAC( Electronic Discrete Variable Automatic Computer ) with a
memory to store program and data.( stored program concept)
2) Second Generation Computers :
• Vacuum tubes were replaced by transistors r e d u c i n g s i z e
• less electricity, less expensive.
• Concept of programming language was developed. High Level Languages like FORTAN
(FORmula TRANslation), COBOL (COmmon Business Oriented Language) developed.
• Magnetic core memory (Primary memory ) and magnetic disk memory (Secondary memory ).
• The popular computers are IBM 1401 and IBM 1620
3) Third Generation Computers:
• Silicon chips or IC(Integrated Circuits) that contain very small transistors were
developed by Jack Kilby
• Transistors were replaced by IC's.
• It reduced size, increased speed and efficiency, and became cheaper.
• High Level Language BASIC (Beginners All Purpose Symbolic Instruction Code ) was
developed .
ACT MLPM 4
• Moore's Law states that the number of transistors on IC's doubles approximately every two
years.
• The popular computers are IBM 360 and IBM 370.
4) Fourth Generation Computers:
• Microprocessors are used (a single chip with Large Scale of Integration (LSI) of electronic
components)
• Later LSI circuits were replaced by VLSI ( Very Large Scale Integration ).
• IBM PC and Apple II are popular computers. Programming Languages like. C, C++, Java [Link]
developed.
e). Fifth Generation Computers:
• They are based on Artificial Intelligence (AI).
• AI is the ability of machines to simulate human intelligence
• Presently in the development stage.
• Common AI programming Languages- LISP and Prolog.
Program:
The set of detailed instructions given to a computer for executing specific tasks.
Programming languages are artificial languages designed to give instructions to the computers.
• Machine language (Low Level Language -LLL).consists of 0's and 1's. This is the only language
understood by the computer.
• Assembly language, with English like words instead of 0's and 1's EDSAC (Electronic Delay Storage
Automatic Calculator ) built in 1949 was the first computer to use assembly language.
• Later, High Level Languages (HLL) like, BASIC, C, C++, Java etc were developed.
Algorithm and Computer programs:
An algorithm is a step by step procedure to solve a problem.
Theory of computing:
• This branch deals with how efficiently problems can be solved based on computation models and
related algorithms. The study is based on a mathematical abstraction of computers called model of
computation.
• The most commonly used model is Turing machine named after the computer scientist Alan Turing.
He is considered as the Father of modern computer science and Artificial intelligence.
Turing machine:
• Introduced by Alan Turing
• Theoretical device that uses symbols on a long tape (acting like memory)
• The tape contains cells with a blank, 0 or 1
• The action decided by the current state, symbol currently being read and table of transition rules.
• Considered as the first theoretical development towards the idea of Artificial Intelligence.
ACT MLPM 5
-23 in 1’s complement form = (11101000)2 (by replacing 0 with 1 and 1 with 0)
Representation of characters
Different methods to represent characters in computer memory are: ASCII, Unicode, ISCII, EBCDIC
ISCII
• It stands for Indian Standard Code for Information Interchange or Indian Script
Code for Information Interchange.
• It is an 8 bit code for representing various languages of India.
ACT MLPM 10
(iii) Registers: These are the temporary storage areas inside the CPU.
3. Storage Unit
Store data and instructions, intermediate results and final results.
4. Output Unit
Supplies the results to the outside world.
Eg:- Monitor, Printer
Hardware
• The tangible and visible parts
Eg:- Processor, Motherboard, Keyboard, etc.
1. Processor
• Processor / CPU / Microprocessor performs all computing and decision making operations and
coordinates the working of a computer.
Eg:- Intel core i3, core i5, core i7, AMD Quadcore
Motherboard
• A motherboard is a Printed Circuit Board to which all the major components of a computer
(processor, memory, etc.) are connected.
Memory
• Memory is used to store data and instructions temporarily or permanently.
• Classified into two: Primary memory and Secondary memory.
ACT MLPM 15
Uses EEPROM chips. Eg:- USB flash drive, Flash memory cards
Input devices
An input device is used to feed data and instructions into the computer.
Output devices
Output device is used to present information from a computer system.
ACT MLPM 17
Different types of output devices are:
2. LCD projector
Uses high intensity light beam to display video, images or computer data on a large screen.
3. Printer
Gives hardcopy output.
Classified into two:- impact and non-impact printers.
Impact printers make direct contact with the paper while printing. Eg:- Dot-matrix printers.
Dot Matrix Printer (DMP)
• Printing material: Ink ribbon
• Cheaper to print, Carbon copy possible, slow, noisy, printer is expensive.
Inkjet printer
• Printing material: Liquid ink
• Quiet, high print quality, printers are inexpensive, ink is expensive.
Laser printer
• Printing material: Ink powder
• Quiet, prints faster, high print quality, Toner is expensive, Device is expensive.
Thermal printer
• Printing material: Heat sensitive paper.
• Quiet, faster, smaller, lighter, consume less power, portable.
4. Plotter
• Produces hard copies of large graphs and designs on the paper.
• Used in the design of cars, ships, aircrafts, buildings, highways etc.
6. Speakers
• Output devices that produce sound.
e-Waste
e-Waste refers to electronic products nearing the end of their "useful life".
Eg:- discarded computers, mobile phones, television sets, refrigerators, etc.
ACT MLPM 18
e-Waste disposal methods
a. Reuse: Second-hand use.
b. Incineration: Controlled, combustion process in which waste is burned at a high temperature.
c. Recycling: Making new products from old devices.
d. Land filling: Soil is excavated and e-waste is buried in it.
• The environmentally responsible and eco-friendly use of computers and their resources is known
as green computing.
Software
System software
It is a set of one or more programs designed to control the operations of a computer.
a. Operating system
• Set of programs that acts as an interface between the user and computer hardware. Example:-
DOS, Windows, Unix, Linux
b. Language processor
• It translates programs written in high level language or assembly language into machine
language.
ACT MLPM 19
Computer languages
High Level Language is like English language and is simpler to understand. Not
understandable to the computer. Example: C++
c. Utility software
• Set of programs which help in system maintenance tasks.
Application software
• Software developed for specific application is called application software.
• It includes general purpose software and specific purpose software.
ACT MLPM 20
CHAPTER 4
Principles of Programming and Problem Solving
Phases in programming
• Problem identification
• Preparing Algorithms and Flowcharts
• Coding the program
• Translation
• Debugging
• Execution and testing
• Documentation
Problem Identification
• In this phase we will be able to identify the data involved in processing, its type and quantity,
formula to be used, activities involved, and the output to be obtained.
Algorithm
• It is a step-by-step procedure to solve a problem.
Characteristics of an Algorithm
• Should begin with instructions to accept inputs.
• Use variables to refer the data
• Each and every instruction should be precise and unambiguous.
• The total time to carry out all the steps in the algorithm must be finite.
• After performing the instructions given in the algorithm, the desired results must be
obtained.
Flowcharts
• The pictorial representation of an algorithm is known as flowchart.
Flowchart symbols
ACT MLPM 22
Debugging
• Programming errors are known as 'bugs'. The process of detecting and correcting errors is called
debugging.
Documentation
• Writing comments in the source code is known as internal documentation.
• It will help in debugging process and program modification at later stage.
• Preparing user manual and system manual are known as external documentation.
ACT MLPM 25
CHAPTER 5
Introduction to Programming
Character set
• Fundamental units(set of valid characters) of C++ Language. It consists of letters, digits, special
characters, white spaces
Tokens
• Fundamental building blocks of C++ program. (Lexical units)
Classification of Tokens
ACT MLPM 26
• Keywords cannot be used as identifiers.
• Special characters or white spaces cannot be used
Eg: score, score1, score_1, INT
ACT MLPM 27
CHAPTER 6
Data Types and Operators
Data types: Used to identify nature and type of data stored in a variable.
Fundamental data types:
Data Memory
Type of value Eg:
type (bytes)
Numerical
float real values 4 datatypes
Float data has a precision of 7 digits and double data has a precision of 15 digits
Type modifiers
• Used to change the size, range or precision of a data type
• Type modifiers in C++ are long, short, signed and unsigned
In the expression a+b, + is the operator and a and b are the operands.
Classification of operators
ACT MLPM 28
Increment (++) and Decrement (--) operators
++ is used to increment the value in a variable by 1.
-- is used to decrement the value in a variable by 1.
a++ (post increment form) and ++a (pre increment form) are same as a=a+1 or a+=1
a-- (post decrement form) and --a (pre decrement form) are same as a=a-1 or a-=1
(A post-form denotes use, then change method and a pre-form denotes change, then use method)
int m=5; int m=5;
n=m++; n=--m;
(Now n -> 5 and m -> 6) (Now n -> 4 and m -> 4)
sizeof operator
It is a unary compile time operator that returns the amount of memory space(in bytes) allocated
for the operand. Eg: sizeof (int) --> gives the value 4 , sizeof(3.2) --> gives the value 8
Precedence of operators
It is the order in which the operations are performed in an expression. The order of execution is ( ), ++,
--, !, Unary +, Unary -, sizeof, *, /,%, +, - etc
(ii) Floating point(Real) expressions: contains real operands. Result is float value.
(b) Relational expressions: contains relational operators. Result is either true or false. Eg: x >y
(c)Logical expressions :contains logical operators. Result is either true or false. Eg: a<b && c>d
Type conversion
• Conversion of the data type of an operand to another.
Two types of conversion:
1. Implicit (Type promotion): This is done by the compiler and the conversion is from
lower data_type to higher.
Eg: 5/2.0 => 2.5 (Here, int datatype of 5 is converted to float by compiler. Thus the result of the
float expression is also float)
2. Explicit (Type casting): This is done by the programmer explicitly and conversion can be to
any data_type.
Eg: 5/(int)2.0 => 2 (Here, programmer uses type casting (int) to convert the float data type of 2.0 to
int. Thus the result of this integer expression is also an integer.)
Statements: Smallest executable unit of a program. C++ statement ends with semicolon (;)
1. Declaration statement: Specifies the type of data that will be stored in a variable.
ACT MLPM 30
Syntax: datatype var_name;
Variable Initialisation:
The keyword const is used to create symbolic constants whose value can never be changed
during program execution.
The multiple use of input/output operators in a single statement is called cascading of I/O
operators.
Eg: cin>>x>>y>>z;
cout<<”Sum=”<<S;
ACT MLPM 31
A sample program
#include<iostream>
using namespace std;
int main()
{
cout<<"Hello, Welcome to C++";
return 0;
}
Comments
Lines in code that are added to describe the program. They provide for internal documentation.
There are two ways to write comments in C++:
• Single line comment: The characters // (two slashes) is used to write single line comments.
• Multiline comments: Anything written within /* and */ is treated as comment
Write a C++ program to input two numbers and find their sum.
#include <iostream>
using namespace std;
int main()
{
int num1, num2, sum;
cout<<"Enter two numbers: ";
cin>>num1>>num2;
sum=num1+num2;
cout<<"Sum of the entered numbers = "<<sum;
return 0;
}
ACT MLPM 32
{
case constant_1 : statement 1; {
break; case 1 : cout<<”One”;
case constant_2 : statement 2; break;
break; case 0 : cout<<”Zero”
case constant_3 : statement 3; break;
break; default :
............................................. cout<<”Invalid”;
default : statement n; }
}
Conditional Operator ( ? : )
It is a ternary operator in C++ . It is an alternative to if ..... else statement
Syntax : (test expression) ? True statement : false statement ;
Eg : (mark>=18) ? cout<<”Passed”: cout<<”Failed” ;
is same as
if (mark>=18) cout<<”Passed”;
else cout<<”Failed” ;
ACT MLPM 34
CHAPTER 8
ARRAYS
Array
Array is a collection of elements of same type placed in contiguous memory location
Eg : A[10] , NUM[20]
Each element in an array can be accessed using its position called index number or subscript.
An array index starts from 0. The elements of an array with ten elements are numbered from 0
to 9.
Array declarations
data_type array name[size]; where size is the number of memory locations in the array.
Eg: int N[10] ;
float A[5] ;
char name[25] ;
Array initialization
Giving values to the array elements at the time of array declaration is known as array
initialization.
Eg : int N[10]={12,25,30,14,16,18,24,22,20,28} ;
float A[5]={10.5,12.0,5.75,2.0,14.5} ;
char word[7]={‘V’ , ‘I’ , ‘B’ , ‘G’ , ‘Y’ , ‘O’ , ‘R’ } ;
Memory allocation for arrays
total bytes = size of data_type x size of the array
Eg:
The number of bytes needed to store the array int A[10] is 4 x 10=40 bytes.
The number of bytes needed to store the array float P[5] is 4 x 5 = 20 bytes.
The memory needed to store the array char S[25] is 1 x 25 is 25 bytes.
The memory needed to store the array int Num[ ]={25,65,14,24,27,36} is 4 x 6 =24
bytes.
Array traversal operation
Accessing each element of an array at least once in a program is called array traversal.
• C++ statement to display the elements of an array N[10]
for(i=0 ; i<10 ; ++i)
cout<<N[i] ;
• C++ statement to input 10 numbers into an array N[10]
for(i=0 ; i<10 ; ++i)
cin>>N[i] ;
Array operations :
1. Traversal :
• Accessing each element of an array at least once to perform any operation is known as
traversal operation.
• Eg. Displaying all the elements of an array
Write a C++ program to input 10 numbers into an array and display the sum of numbers
#include<iostream>
using namespace std;
int main()
[
int N[10], i , s=0 ;
cout<<”Enter 10 numbers “;
for(i=0 ; i<10 ; ++i)
{
ACT MLPM 37
cin>>N[i] ;
s=s+N[i] ;
}
cout<<”Sum of 10 numbers is “<<s;
return 0;
}
(2). Sorting:
• Arranging elements of an array in ascending or descending order.
(a). Selection sort:
• The array is divided into sorted part and unsorted parts.
• To arrange in ascending order, first find the smallest element and exchange it with the first
element.
• Then find the second lowest element and exchange the element in second position.
• This process is repeated till the array is sorted.
The process of finding the smallest element and exchanging it with the element in respective
position is known as a ' PASS '.
(b). Bubble sort:
• This repeatedly steps through the list, compares each pair of adjacent items and swaps them if
they are in the wrong order.
• This passing procedure repeats until no swaps are required, indicating that the list is sorted.
C++ code to input N elements into an array AR and sort in ascending order
Selection sort Bubble sort
for(I=0; I<N; I++) for(I=0; I<N; I++)
cin>>AR[I]; cin>>AR[I];
for(I=0; I < N-1; i++) for(I=1; I<N; I++)
{ for(J=0; J<N–I; J++)
MIN=AR[I]; if(AR[J] > AR[J+1])
POS=I; {
for(J = I+1; J < N; J++) TEMP = AR[J];
if(AR[J]<MIN) AR[J] = AR[J+1];
{ AR[J+1] = TEMP;
MIN=AR[J]; }
POS=J; cout<<"Sorted array is: ";
} for(I=0; I<N; I++)
if(POS != I) cout<<AR[I]<<"\t";
{
AR[POS]=AR[I];
AR[I]=MIN;
}
}
cout<<"Sorted array is: ";
for(I=0; I<N; I++)
cout<<AR[I]<<"\t";
(3). Searching:
• Process of finding the location of the given element in an array.
(a) Linear Search(Sequential Research)
• Linear search or sequential search is a method for finding a particular value in a list.
• Linear search consists of checking each element in the list, starting from the first element until
ACT MLPM 38
return 0; cout<<"\nColumn sum of the 2D array is\n";
} for(col=0; col<n; col++)
cout<<csum[col]<<"\t";
return 0;
}
To find the transpose of a matrix To find the sum of major diagonal elements of
#include <iostream> a matrix
using namespace std; #include <iostream>
int main() using namespace std;
{ int ar[10][10], m, n, row, col; int main()
cout<<"Enter the order of matrix: "; { int mat[10][10], n, i, j, s=0;
cin>>m>>n; cout<<"Enter the rows/columns of square matrix: ";
cout<<"Enter the elements\n"; cin>>n;
for(row=0; row<m; row++) cout<<"Enter the elements\n";
for(col=0; col<n; col++) for(i=0; i<n; i++)
cin>>ar[row][col]; for(j=0; j<n; j++)
cout<<"Original matrix is\n"; cin>>mat[i][j];
for(row=0; row<m; row++) cout<<"Major diagonal elements are\n";
{ for(i=0; i<n; i++)
cout<<"\n"; {
for(col=0; col<n; col++) cout<<mat[i][i]<<"\t";
cout<<ar[row][col]<<"\t"; s = s + mat[i][i];
} }
cout<<"\nTranspose of the entered matrix is\n"; cout<<"\nSum of major diagonal elements is: ";
for(row=0; row<n; row++) cout<<s;
{ return 0;
cout<<"\n"; }
for(col=0; col<m; col++)
cout<<ar[col][row]<<"\t";
}
return 0;
}
Multi-dimensional arrays
A 2D array where each element is another array is called a 3D(Three Dimensional) array.
Declaration syntax: data_type array_name[size_1][size_2][size_3];
Similarly, more sizes can be specified while declaring arrays to form multidimensional arrays.
ACT MLPM 41
CHAPTER 9
String Handling and I/O Functions
String handling using arrays
A character array can be used to store a string. A null character '\0' is stored at the end of the
string. This character is used as the string terminator.
Memory allocation for strings
The memory required to store a string will be equal to the number of characters in the string
plus one byte for null character.
char string1[10]=”Bill”; (10 bytes will be allocated, null character is added as
delimiter for the string, last 5 bytes will be unused)
char string2[ ]=”Program”; (8 bytes will be allocated – 7 for the string and 1 for’\0’)
ACT MLPM 42
Syntax : [Link](variable) ; [Link](array name , size) ;
Eg: [Link](ch) ; // accepts a single character
[Link]( str10) ; // accepts a string of maximum 10 characters
• getline( ) - used to input a string
Header file : iostream
Syntax : [Link](array name , len) ;
Eg : [Link](str,10); // accepts a string of maximum 10 characters
[Link](str,10,'c') ; // accepts a string or maximum 10 characters or a string up to the
character ' c'
• put( ) - used to display a character
Header file : iostream
Syntax : [Link](variable or character constant) ;
Eg : char ch='B' ;
[Link](ch) ; // displays B
[Link]('P') ; // displays P
• write( ) - used to display a string
Header file : iostream
Syntax : [Link](arraymame , len) ;
Eg : char str[20]=”HELLO FRIENDS” ;
[Link](str,5) ; // displays HELLO
ACT MLPM 43
CHAPTER 10
FUNCTIONS
Modular Programming / Modularization
The process of breaking large programs into smaller sub programs is called modularization.
Merits of Modular programming
• Reduce the size of the program
• Reduce program complexity
• Less chance of error
• Improve re usability
Demerits of Modular programming
• Proper breaking down of the problem is a challenging task
• Each sub program should be independent
Function
Function is a named unit of statements in a program to perform a specific task.
main() is an essential function in C++ program . The execution of the program begins in main().
Two types of functions
• Predefined functions / built-in functions - ready to use programs
• User defined functions
Arguments / Parameters
The data required to perform the task assigned to a function. They are provided within the pair
of parentheses of the function name.
Return value
The result obtained after performing the task assigned to a function. Some functions do not
return any value
Built-in functions
Type & Function Use Syntax Example
Header File
strlen( ) find the length of the int strlen(string); strlen(“COMPUTER”) ; //
string ( number of displays 8
characters)
strcpy( ) copy a string to strcpy(string1, char str[20];
another string2); strcpy( str,“welcome”) ; //the
string “welcome” will be stored
String in the variable str
(cstring)
strcat( ) append one string to strcat(string1,string2) cout<<strcat(“Welcome ” , “to
another (join two ; C++”) ; // displays Welcome to
strings) C++
strcmp( ) compare two strings strcmp(string1,string2 cout<<strcmp(“Hello”,”Hello”); //
); displays 0
strcmpi() compare two strings strcmpi(string1,string cout<<strcmpi(“HELLO” , “Hello”)
ignoring the cases 2) ; // displays 0
abs( ) find the absolute value int abs( int) ; cout<<abs(-5) ;
of a number // displays 5
sqrt( ) Find square root of a double sqrt(double) ; cout<<sqrt(16) ;
Mathematical number // displays 4
(cmath)
pow( ) find the power of a double pow(double, cout<<pow(3,2) ;
ACT MLPM 44
number double) ; // displays 9
sin() find the sine value of double sin(double); cout<<sin(90*3.14/180);
an angle. (angle must be in displays 1
radians)
cos() Find the cosine value double cos(double); cout<<cos(0*3.14/180); displays
of an angle (angle must be in 1
radians)
isupper( ) to check whether a int isupper (char) ; cout<<isupper('A') ;
character is in upper // displays 1
case(capital letter) or // displays 0
not. cout<<isupper('d') ;
islower( ) check whether a int islower (char) ; cout<<islower('A') ;
character is in lower // displays 0
case(small letter) or cout<<islower('d') ;
not. // displays 1
isalpha( ) check whether a int isalpha(char) ; cout<<isalpha('B') ;
character is an // displays 1
alphabet or not. cout<<isalpha('8') ; //displays 0
isdigit( ) check whether a int isdigit(char c) ; cout<<isdigit('8') ; // displays 1
character is digit or cout<<isdigit('b') ; // displays 0
Character not
(cctype) isalnum() check whether a int isalnum(char) ; cout<<isalnum('8') ; // displays 1
character is 1cout<<isalnum('a') ; // displays
alphanumeric or not. 1 cout<<isalnum('+') ; // displays
0
toupper() convert the given char toupper(char) ; cout<<(char)toupper('b') ; //
character into its displays B
uppercase.
tolower( ) convert the given char tolower(char) ; cout<<(char)tolower('B'); //
- character into its lower displays b
case.
Conversion itoa() convert an integer itoa(int n, char c[], int int n = 2345;
functions value to string type. len); char c[10];
cstdlib itoa(n, c, 10);
cout << c; // displays "2345"
atoi() returns the integer int atoi(char c[]); int n;
value of the string char c[10] = "2345";
n = atoi(c);
cout << n; // displays number
2345
I/O setw() set the width for the setw(int); char s[]="hello";
Manipulating subsequent string cout<<s<<setw(10)<<"friends";
function // hello friends
(ciomanip)
ACT MLPM 45
User defined functions
The syntax of a function definition is given below:
data_type function_name(argument list)
{
statements in the body;
}
The data_type is any valid data type of C++. The function_name is a user defined word
(identifier).
The argument list is a list of parameters, i.e. a list of variables preceded by data types and
separated by commas.
Example 1 Example 2 Example 3 Example 4
int sum(int a , int b) void sum(int a , int b) void sum(i) int sum(i)
{ { { {
int s=a+b ; int s=a+b ; cin>>a>>b; cin>>a>>b;
return s; cout<<”Sum=”<<s; int s=a+b ; int s=a+b ;
} } cout<<”Sum=”<<s; return s ;
} }
Prototype of functions
A function prototype is the declaration of a function
Syntax : data_type function_name(argument list);
Eg : int sum( int , int ) ;
void sum( ) ;
int sum( ) ;
Arguments of functions
• Arguments or parameters are the means to pass values from the calling function to the called
function.
• The variables used in the function definition as arguments are known as formal arguments.
• The variables used in the function call are known as actual (original) arguments.
ACT MLPM 46
Scope and life of variables and functions
Local variable - declared within a function or a block of statements.
Global variable - declared outside all the functions.
Local function - declared within a function or a block of statements and defined after the
calling function.
Global function - declared or defined outside all other functions.
ACT MLPM 47
CHAPTER 11
Computer Networks
• It is a group of computers and other devices connected to each other electronically through a
communication medium
Need for Network
Resource sharing
• Any hardware /software resource in one system can be shared with other systems in the
network.
Price performance ratio
• The cost of purchasing licensed software for each computer, can be reduced by purchasing
network versions of such software in a network.
Communication
• The computer network helps users to communicate with any other computer in the network
through its services like e-mail, chatting, video conferencing, etc.
Reliability
• In a network, it is possible to backup data on multiple computers. This helps users to retrieve
data in the case of failures in accessing data.
Scalability
• Computing capacity can be increased or decreased easily by adding or removing computers
to the network.
Some key terms
Bandwidth: It measures the amount of data that can be sent over a specific connection in a
given amount of time.
Noise: It is unwanted electric or electromagnetic energy that lowers the quantity of data
signals.
Node: Any device which is directly connected to a network is called a Node.
Data Communication System
• Data Communication is the exchange of digital data between any two devices through a medium
of transmission.
• 5 basic elements:
Message: It is the information to be communicated.
Sender: The computer or devices that is used to sending messages.
Receiver: The computer or device that receives the messages.
Medium: It is the physical path through which a message travels from the sender to the receiver.
Protocol: The rules under which message transmission takes place between the sender and the
receiver.
Communication Medium
• The medium for data transmission over a computer network is called communication channel
or communication medium.
• Two types: (1) Guided (2) Unguided
Guided Medium
• Coaxial cable, twisted pair cable (Ethernet cable) and optical fibre cable
(a) Twisted pair cable (Ethernet cable)
• Most widely used
• Two types: (1) Unshielded Twisted pair (UTP), (2) Shielded Twisted Pair (STP)
Characteristics of UTP cable
• Low cost
• Thin and flexible
• Easy installation
ACT MLPM 48
• Carry data upto a length of 100m
Characteristics of STP cable
• Better immunity against noise
• Expensive
• Difficult to install
• RJ-45 connector is used to connect UTP/STP twisted pair cable to a computer.
(b) Coaxial cable
• Carries data to long distance 185-500m
• High band width
• Less noise
• Thicker than twisted pair
• Less flexible
• Difficult to install
(c) Optical fibre cable
• Data travels as fast as light
• High bandwidth
• Carries data for a long distance
• It uses light for data transmission
• Most expensive and efficient
• Installation and maintenance are difficult
Unguided Medium
• Electro magnetic waves are used for wireless communication
(a) Radio Waves
• Frequency range is 3KHz to 3 GHz
• Used for short and long distance communication
• Waves are transmitted in all directions
• Inexpensive than wired media
• Can penetrate through most objects
• Transmission can be affected by motors and other electric equipments
• Less secure
• Permission required for radio wave transmission
(b) Microwaves
• Frequency range is 300MHz to 300GHz
• Travels in straight line
• Can not penetrate any solid object
• Inexpensive than wired media
(c) Infrared Waves
• Frequency range is 300GHz to 400THz
• Used for short range communication
• Line of sight transmission
• Only two devices can communicate at a time
• Can not cross solid objects
• The longer the distance the weaker the performance
Wireless Communication technologies using radio waves
(a) Bluetooth
• Frequency range is 2.402GHz to 2.480GHz
• Used for short distance communication
• Used in cell phones, laptops, mouse, keyboard etc.
• It cannot connect upto 8 devices simultaneously
• Slow data transfer rate
ACT MLPM 49
(b) Wi-Fi
• Frequency range is 2.4GHz to 5GHz
• Data transmission speed upto 54Mbps
• It can be used to connect more number of devices simultaneously
• Used for communication upto 375ft
(c) Wi-MAX
• Worldwide Interoperability for Microwave Access
• Frequency range is 2GHz to 11GHz
• Used to provide high speed wireless internet access over very long distances
• Hundreds of users can connect to a single station
• High speed connection upto 70Mbps
• Weather conditions may interrupt the signal
• High power consumption
(d) Satellite link
• Uses Geostationary satellites
• These satellites contains an electronic device called transponder
• Transponders are used to amplify and re-broadcast signals to earth
• Transmission of signals from earth to a satellite is called uplink
• Transmission of signals from satellite to earth is called Downlink
• Uplink frequency is 106GHz to 30.0GHz
• Downlink frequency is 1.5GHz to 20.0GHz
• It can cover a large area of the earth
• Expensive
• Requires legal permission and authorisation
Data Communication Devices
• Its an interface between computer and the communication channels
Network Interface Card(NIC)
• It breaks up data into manageable units
• Translate the protocol
• Some NIC cards have wireless connection
• Data transfer rate is 1Gbps
Hub
• Used to connect devices of same network
• It transmit the packet to all other computers connected to it
• It increases the network traffic and reduces the effective band width
Switch
• A switch is a device that connects several computers to form a network.
• It an intelligent device, because it can transmit the received data to the destination only.
• It will store the addresses of all the devices connected to it .
Repeater
• Used to regenerates the signals through a communication medium
Bridge
• A bridge is a device used to segmentize a network.
• A network can be split into different segments and can be interconnected using a bridge.
• This reduces the amount of traffic on a network.
Router
• A router is a device that can interconnect two networks of the same type using the same
protocol.
• It can find the optimal path for data packets to travel and reduce the amount of traffic on a
network.
ACT MLPM 50
• It can cover an area of a radius of few meters.
LAN (Local Area Network)
• LAN is a network of computing and
• communicating devices in a room building or campus.
• It can cover an area of few meters to few kilometers.
MAN (Metropolitan Area Network)
• MAN is a network of computing and communication devices within a city.
• It can cover an area of a few kilometers to a few hundred kilometers radius.
• MAN is usually formed by interconnecting a number of LANs and individual computers.
WAN (Wide Area Network)
• WAN is a network of computing and communicating devices crossing the limits of a city,
country, or continent.
• It can cover an area of hundreds of Kilometers in radius.
Summary of PAN, LAN, MAN, WAN
Parameter PAN LAN MAN WAN
Transmission
High speed High speed Moderate speed Low speed
speed
Networking Moderately
Negligible Inexpensive Expensive
cost expensive
ACT MLPM 53
File name
Protocol
• Indicate the protocol is used to access the information specified in the domain
Domain Name
• It is the name assigned to a server through domain name system
File Name
• It is the file to be opened
Generic Domain Names Country Specific Domain Names
.com Commercial Business .in India
.edu Educational Institutions .au Australia
.gov Government agencies .ca Canada
.mil Military .ch China
.net Network organisations .jp Japan
.org Nonprofit organisations .us USA
ACT MLPM 55
CHAPTER 12
Internet and Mobile Computing
History of internet
• Internet is developed by United States Department of Defence by the name ARPANET
(Advanced Research Project Agency Network)
• ARPANET uses TCP/IP protocol for communication
• ARPANET considered as first wide area connection
• Vincent Gray Cerf is considered as the father of internet
• Tim Berners Lee proposed the idea of World Wide Web(WWW)
• He and his team are credited with inventing HTTP and HTML
• Internet is an interconnected system of computer networks that serves the users all over the
world
• Intranet is a private computer network similar to internet
• When an intranet is made accessible to some computers that are not part of a company’s private
network it is called an extranet
Connecting the computer to the internet
• The following hardware and software requirements are required to connect a computer to the
internet
1. A computer with network interface card
2. Modem
3. Telephone connection
4. An internet account given by an Internet service provider(ISP)
5. Software like Browser
Types of connectivity
Dial-up Connectivity
• Uses conventional telephone line and a dial up modem to dial and connect to the server at
the Internet Service Provider
• These type of connection uses a 56kbps modem
• Maximum speed is 56kbps
• Less costly
• Requires exclusive use of telephone connection
• Popular broadband technologies are Integrated Service Digital Network(ISDN), Cable Internet,
Digital Subscriber Line(DSL), Leased Lines and Fiber to the Home(FTTH)
1. Integrated Services Digital Network(ISDN)
• Capable of transporting voice and database
ACT MLPM 56
• Uses two lines, one for voice and other for data
• Data transfer rates upto 2Mbps
2. Cable Internet
• Uses coaxial cables laid for television signal transmission to our home
• Uses a cable modem
• It can provide speed between 1Mbps to 10Mbps
3. Digital Subscriber Line (DSL)
• Uses standard telephone lines
• Use the copper telephone lines for both internet communication and for making the voice
calls simultaneously
• ADSL(Asymmetric Digital Subscriber Line) is the common subcatagory
• Speed ranges from 256Kbps to 24Mbps
• Most popular broadband service available in india
4. Leased line
• It is the dedicated lines used to provide internet facility
• Speed ranges from 2Mbps to 100Mbps
5. Fibre To The Home (FTTH)
• Uses optical fibers for data transmission
• High speed connectivity
Wireless broadband connectivity
• Popular wireless broadband accesses are Mobile Broadband, Wi-Max, Satellite Broadband and Wi-
Fi
1. Mobile Broadband
• Its a wireless internet access using mobile phone
• The modem is built into the devices like mobile phones, tablet etc.
• Offer the freedom to allow the user to access the internet from anywhere on the move
• It uses the cellular network of the mobile phones for data transmission
2. Wi-Max
• Worldwide Interoperability for Microwave Access
• Its an alternative for wired broadband
• It can provide wireless internet access upto a distance of 50KM
• It can provides speed upto 70Mbps
3. Satellite broadband
• Internet connectivity is provided through satellite
• A very small aperture Terminal (VSAT) dish antenna and a transceiver (Transmitter and
Receiver) are required at the users location
• Speed upto 1Gbps
• Most expensive forms of broadband internet
• Used by banks, stock exchanges, governments etc.
Internet Access sharing methods
1. Using LAN
• The internet connection in a computer can be shared among other computers in the LAN
• It can done using the features of the Operating system or using proxy server software
2. Using Wi-Fi network
• The internet connectivity can shared using Wi-Fi router or wireless network access point,
popularly called hotspot
• It has a range of about 100 meters
• Less secure than wired connection
3. Using Li-Fi network
• Fast optical version of wifi
ACT MLPM 57
• Data rate is 100Mbps
• It can be used in aircrafts and hospitlas
Services on Internet
• The internet offers a variety of services like WWW, e-mail, search engines, social media.
1) World Wide Web (WWW)
• WWW is a huge client-server system consisting of millions of clients and servers connected
together.
a) Browser :
• A web browser is a software that we use to retrieve or present information and to navigate
through web pages in the World Wide Web.
• Some common browsers are Google Chrome, Internet Explorer, Mozilla Firefox, Opera, and
Safari.
b) Web browsing:
• Traversing through the web pages of World Wide Web is called web browsing.
2) Search engines
• Internet search engine websites are special programs that are designed to help people to find
the information available in World Wide Web.
• Search engine programs search documents available on the World Wide Web for specified
keywords.
• It returns a list of the documents/web pages matching the keywords.
• Some of the most popular web search engine sites are Google, Bing, Yahoo Search, Ask, etc.
3) E-Mail
• Electronic mail or e-mail is a method of exchanging digital messages between computers
over Internet.
Sections of an e-mail
To (Recipient Address), Cc (Carbon copy), Bcc (Blind carbon copy), Subject, Content
Advantages of using e-mail
Speed, Easy to use, Provision of attachments, Environment friendly, Reply to an e-mail, Cost-
effective, Available anywhere anytime
Disadvantages of using e-mail
E-mails may carry viruses, Junk mails
4) Social media
• Social media refers to the use of mobile and web-based technologies through which
individuals and communities can create, share, discuss and modify content.
Classification of social media.
a) Internet forums
• It is an online discussion website where people can engage in conversations in the form of
posted messages.
• e.g. Ubuntu Forum.
b) Social blogs
• It is a discussion or informational website consisting of entries or posts displayed.e.g. Blogger
and WordPress
c) Microblogs
• Microblogs allow users to exchange short sentences, individual images or video links. e.g.
[Link]
d) Wikis
• Wikis allow people to add content or edit existing information in a web page, to form a
community [Link]
e) Social networks
ACT MLPM 58
• Social networking sites allow people to build personal web pages and then connect with
friends to communicate and share content. e.g. [Link] and LinkedIn.
f) Content communities
• Content communities are websites that organise and share contents like photos, videos, etc.
e.g. YouTube
Advantages of social media
• Bring people together, Plan and organise events, Business promotion, Social skills
Limitations in use of social media
• Intrusion to privacy, Addiction, Spread rumours
Cyber Security
• It is used to provide protection of valuable information such as credit card information from
unauthorized access.
1) Computer Virus
• A virus is a bad program to damage routine working of a computer system.
• A computer virus is a program that attaches itself to another program or file enabling it to
spread from one computer to another without our knowledge and interfereswith the normal
operation of a computer.
2) Worm
• It is a stand alone malware program that replicates itself in order to spread to other
computers.
• Worms spread from computer to computer on its own.
3) Trojan Horse
• It appears as a useful software but it is harmful software’s and it will delete useful softwares
or files.
4) Spams
• Sending an email without recipients consent to promote a product or service is called
spaming. Such an email is called spam
5) Hacking
• It is a process of trespassing computer networks.
• In computer networking, hacking is a technical effort to manipulate the normal behavior of
network connections and connected systems.
• Hacking performed by computer security experts are called ethical hacking and such
hackers are called white hats
• Computer criminals break into secure networks to destroy data or make the network
unusable. Such hackers are called black hats
• Grey hat hackers fall between white and black hackers
6) Phishing
• It is an attempt to get other information such as username, password, bank a/c details etc by
posing as the original website, mostly that of banks and other financial institutions.
• Phishing websites have URLs and home pages similar to their original ones.
• The act of creating such a misleading website is called spoofing.
7) Denial of Service attack
• Due to this attack the computer forced to restart and this result refusal of service to the
genuine users.
8) Man in the Middle attacks
• It is an attack in which the an attacker secretly intercepts electronic messages send by the
sender to the receiver and then modifies the messages and retransmit it to the receiver.
Preventing network attacks
1) Firewall
ACT MLPM 59
• A firewall is a system of computer hardware and software that provides security to the
computer network in an organisation.
• A firewall controls the incoming and outgoing network traffic by analysing the data
2) Antivirus scanner
• It is a tool used to scan computer files for viruses, worms and Trojan horses and cure the
infected system.
• When an antivirus program scans a file and notices that the file matches a known piece of
malware, the antivirus program stops the file from running, and puts it into ‘quarantine’.
• Quarantine is a special area for storing files probably infected with viruses.
3) Cookies
• Cookies are small text files that are created when we visit a website that keep track of our
details.
• Cookies remembers our user name, preferences, e-mail address, etc.
Guidelines for using computers over Internet
• Do not open any e-mail attachment that you are not sure about the sender.
• Download files only from reputed sources.
• Do not use/copy software that you cannot confirm the origin.
• Avoid clicking on pop-up advertisements.
• Make sure the firewall is set and turned on.
• Use strong passwords. Change passwords at regular intervals.
• Update the virus definitions of your antivirus program periodically online.
• Keep a regular backup of your important files.
• Be careful about giving personal data online.
Mobile computing:
• It is a technology that has computing capability and can transmit/receive data while in motion.
• It requires devices like smart phones, laptop etc and wireless internet connection.
(a) First generation networks ( 1G ):
• They are considered as first analogue wireless telephone technology developed around 1980.
• They are designed for voice calls.
(b). Second generation networks ( 2G ):
This network introduced Multi Media Service(MMS) and message service. GSM ( Global System for Mobile
), and CDMA ( Code Division Multiple Access )
GSM:
• GSM is a globally accepted standard for mobile transmission.
• It uses narrow band TDMA (Time Division Multiple Access )allows simultaneous calls on the same
radio frequency rang of 900 MHz to 1800 MHz.
• The network is identified using the SIM( Subscriber Identity Module ).
GPRS (General Packet Radio Services )
• It is a packet oriented data service on GSM
EDGE (Enhanced Data rates for Global Evolution )
• It is a digital mobile phone technology that is three times faster than GPRS.
• It is used for voice communication and internet connection.
CDMA (Code Division Multiple Access ).
• It provides wider coverage than GSM and provides better security to mobile network, better
reception even in low signal strength conditions.
• In CDMA several transmitter can send information at the same time over a single channel.
(c). Third Generation networks (3G) :
• This network provides high data transfer rates and offers high speed wireless broad band
services.
• The access part in 3G network uses WCDMA(Wideband CDMA)
ACT MLPM 60
(d ). Fourth Generation networks (4G ):
• Also called LTE (long Term Evolution ) .
• It provides high speed internet facilities, good quality images and videos than TV.
• The access part in 4G network uses OFDMA (Orthogonal Frequency Division Multiple Access.).
• 4G is also referred as 'MAGIC' (Mobile multimedia Any-where, Global mobility solutions over,
Integrated wireless and Customised service).
Mobile communication services:
(a). SMS (Short Message Service):
• It is the transmission of short text messages to and from a mobile phone,fax machine. When a
message is sent,
• The message reaches a SMSC ( Short Message Service Centre), that allows 'store and forward'
mechanism .
• It uses protocol SS7 ( Signalling System No. 7).
• The first SMS message was 'Merry Christmas ' .
(b). MMS (Multimedia Message Services )
It allows sending multimedia content such as text, picture, audio and video files.
(c) Global Positioning System (GPS):
• It is a satellite based navigation system that is used to locate a geographical position anywhere
on earth.
• It is used for vehicle navigation, aircraft,ship navigation, fishing etc.
• It is maintained by the US Defence Department and is freely accessible to any one with a GPS
receiver.
• They are now integrated with mobile phones.
(d) Smart cards:
• It is like an ATM card that have a memory chip which stores and transacts data.
• The data is protected and easy to carry. In mobile communication the smart card technology is
used in SIM (Subscribers Identity Module ) for GSM phone systems.
• A SIM card is used as an identification proof.
Mobile Operating Systems:
It is the OS used in mobile devices like smart phone, tablet etc.
Eg.
• Android from Google
• iOS from Apple
• BlackBerry OS from Blackberry
• Windows Phone from Microsoft.
Android OS:
• It is a Linux based OS designed mainly for touch screen mobile devices.
• The interface of Android OS is based on touch inputs like swiping, tapping, pinching and reverse
pinching to manipulate on screen objects.
• Android's popularity is due to its open source nature.
...........................................................
ACT MLPM 61
ACT MLPM 62