Computer Applications
Computer Applications
(overview of a computer )
● A computer is an electronic device that accepts
input ,processes data ,stores data ,and produces
output, according to a series of instructions.
● Hardware refers to the physical components of the
computer such as keyboard, monitor etc.
● Software is the instructions or program that makes
the computer work.
● User is a person who operates the computer
system.
🞂 High speed
🞂 Accuracy
🞂 Storage capacity
🞂 Versatile
🞂 Reduced Cost
🞂 Reliability
❖Versatile
❖1.Input Unit
❖c) Registers
❖a)Main memory
❖b)Secondary memory
❖4. Output Unit
INPUT UNIT:
An input device is any hardware component that allows
to enter data and instructions into a computer. Some of
the input devices are keyboard, mouse, microphone,
scanner.
CENTRAL PROCESSING UNIT:
The CPU is the main part of a computer. It is also
known as heart or brain of the computer system as it
follows the instructions of the software/program to
manipulate data into information.
It consists of three major units:
i. Control Unit
ii. Arithmetic and Logic Unit
iii. Registers
CONTROL UNIT:
Control unit controls and directs the transfer of
program instructions and data between various units.
ARITHEMATIC AND LOGIC OPERATOR (ALU):
The ALU of a computer system is the place where the
actual execution of the instructions takes place during
the processing operation. It performs
⮚ Arithmetic operations like addition(+),
subtraction(-), multiplication(*) and division(/).
level language
⮚ Introduction of microprocessors.
⮚ 1 MARK QUESTIONS
⮚ 4) Expand ENIAC.
⮚ 6) Expand EDVAC.
⮚ 8) Expand UNIVAC.
⮚ 2 MARK QUESTIONS
⮚ 1) Write any two features of the first generation
computers.
⮚ 5 MARK QUESTIONS
EVOLUTION OF COMPUTERS
Abacus: Abacus is the first calculating device which
is designed by the Chinese about 5000 years ago.
Abacus was mainly used for addition, subtraction and
later for division and multiplication.
1)Napier’s Bones:
John Napier invented Napier’s bones in 1617. It
was used for multiplication.
2)The Slide Rule:
The slide rule was invented by William Oughtred in
1625. It uses logarithms to perform multiplication and
division using addition and subtraction.
APPLICATION OF COMPUTERS
► Computers in education
► Computers in industry
► Computers in communication
► Computers in business
❖Used in astronomy.
1 MARK QUESTIONS
❖2 MARK QUESTIONS
▪ Analog computers
▪ Digital computers
▪ Hybrid computers
ANALOG COMPUTERS:
Analog computers are used for measuring
continuous quantities. They are used measuring
voltage, current, speed, temperature etc. Some of the
analog devices are thermometer, speedometer etc.
Accuracy is limited since they deal with quantities that
vary continuously. Calculations take place concurrently
and hence processing is faster.
DIGITAL COMPUTERS:
The digital computers operates on discrete data. They
convert data into digits, 0’s and 1’s. Analog computers
are much faster than digital computer and digital
computers are far more accurate than analog
computers. These computers are used for general and
special purpose.
Hybrid computers:
A combination of analog and digital computers
those are capable of inputting and outputting both
digital and analog signals.
In hospitals analog devices measure patient’s heart
beat, bloodpressure etc. These are then converted into
numbers and supplied to digital components in the
system.
Classification of computers based on configuration:
• Micro computers
• Mini computers
• Mainframe computers
• Super computers
MICROCOMPUTERS:
It is also known as personal computers. It contains
one or more processors. It provides access to a wide
variety of computing applications. Personal computers
are available as desktop or portable models. PC’s are
built by IBM, Dell, Lenovo, Sony, HP etc. These are
commonly used in the offices and at home. They are
also used for (small )business and engineering
application.
personal computers can be categorized into:
❑Desktop computers
❑Portable computers
LINE PRINTER:
❑Noisy to operate.
❖Slow in printing.
❖The speed of the printer is measured in characters
per second (cps).
⚫ No striking mechanism.
graphic images.
▪ It is very fast.
Byte 20
1 Kilo byte(1 KB) 210 bytes(1024 Bytes)
1 Mega byte(1 MB) 220 bytes
1 Giga byte(1 GB) 230 bytes
1 Tera byte(1 TB) 240 bytes
1 Peta byte 250 bytes
1 Exa byte 260 bytes
1 Zeta byte 270 bytes
1 Yotta byte 280 bytes
1 Bronto byte 290 bytes
1 Geop byte 2100 bytes
SOFTWARE CONCEPTS
Software is the instructions or programs that makes
the computer work.
TYPES OF SOFTWARE: Software is classified into two
categories.
1)System software
A) Operating system
B) Language translators
C) Utility software
2) Application software
A) General purpose
B) Specific purpose
System software: System software is a collection of
system programs to perform common tasks.
The different types are :
1)Operating system
2)Language translators
3)Utilities
Operating system: An operating system is a set of
programs which acts as an interface between the
user and the computer.
Examples of operating systems are Unix , Linux,
MS-DOS, Microsoft Windows.
Computer languages:A computer language can be
classified in the following categories.
1) Low level languages
a) Machine level language
b) Assembly level language
2) High level language
a) General purpose languages
b) Specific purpose languages
Machine level language: Machine language is the only
language of the system and these are sequence of
machine instructions. These instructions are
represented by a sequence of 1’s and 0’s.
Example :- 0001 00110010 Load the data
Advantages
Disadvantages
⮚ It is machine dependent.
⮚ Debugging is difficult.
⮚ It is difficult to modify.
Disadvantages
⮚ It is machine dependent.
⮚ It is machine independent.
Disadvantages
⮚ Slower in execution.
⮚ Requires a translator or compiler to convert source
code to object code.
⮚ 1. Assemblers
⮚ 2. Compilers
⮚ 3. Interpreters
⮚ Memory management
⮚ Process management
⮚ Device management
⮚ File management
⮚ Allocation
⮚ De allocation
⮚ Schedule a process
Device management
The device management functions are
⮚ Secure files
❖File management.
❖Directory management.
❖Portability.
❖Multi user.
❖Multitasking.
❖Security.
❖Machine independent.
❖Multi user.
❖Multitasking.
❖Security.
❖Multitasking.
❖Multiuser.
❖Switching between applications are easy.
❖Easy installation.
✔ Problem Definition
✔ Problem Analysis
✔ Program documentation
❖Characteristics of an algorithm:
Disadvantages of algorithm:
It is time consuming and cumbersome as an algorithm
is developed first which is converted into a flowchart
and then into a computer program.
Analysis of algorithm: There may be more than one
algorithm to solve a problem. The choice of a
particular algorithm depends on the following.
• Space complexity: The amount of memory needed
by the algorithm to complete its run.
• Time complexity: The amount of time needed by
the algorithm to complete its run.
When we analyse an algorithm there are three cases.
🞂 Advantages of flowcharts:
🞂 It is easy to debug.
PROGRAMMING CONSTRUCTS:
Programming constructs basically represent the
facilities available in a programming language using
which proper structured programs can be developed.
* Sequence construct
* Selection construct
* Iteration construct
Example 1
if (per >= 60)
output “ First class”
else if (per >= 50)
output “Second class”
else if (per >= 35)
output “Pass”
else
output “Fail”
Example 2
if((a>b) and(a>c))
l=a
else if (b>c)
l=b
else
l=c
MULTIPLE SELECTION STATEMENT: If we have to
choose from one of the many alternatives, we can
implement it using the if-else-if statement. The
complexity of such programs increases when the
number of alternatives increases.
The process can be simplified with the usage of
multiple selection decision statement. The statement
tests the value of a variable against a list of values
and when a match is found the corresponding block
of statement is executed.
Example
switch(operator)
{
case ‘+’ : {
result = a + b;
break;
}
case ‘-’ : {
result = a - b;
break;
}
case ‘*’ : {
result = a * b;
break;
}
case ‘/’ : {
result = a / b;
break;
}
default : output “wrong operator”
}
ITERATION CONSTRUCT: Iteration is the ability of a
programming language to allow the user to repeat
the execution of a certain set of statements again
and again until a requirement or condition is
satisfied. Iteration is also called as looping.
Iteration structure can be used to implement the
following statements.
► while
► do- while
► for
WHILE STATEMENT : This structure is also called as
the “pre- tested” iteration structure. In this structure,
the checking of the requirement or condition is done
at the beginning of the structure. The set of
statements in the structure is executed again and
again until the test condition is true. If the test
condition becomes false control is transferred out of
the structure.
Example
sum = 0;
while(n>0)
{
digit = n % 10;
sum = sum + digit;
n = n / 10;
}
Program to find the sum of all the dgitis of a number
using while statement.
◦ #include<iostream.h>
◦ #include<conio.h>
◦ Void main( )
◦ {
◦ int digit,num;
◦ int sum=0;
◦ clrscr();
◦ cout<<"Enter the number:"<<endl;
◦ cin>>num;
◦ while(num!=0)
◦ {
◦ digit=num%10;
◦ num=num/10;
◦ sum=sum+digit;
◦ }
◦ cout<<"The sum of the digits are:"<<sum<<endl;
◦ getch();
◦ }
do- while STATEMENT: This structure is also called as
the “post- tested” iteration structure. In this
structure, the checking of the requirement or
condition is done at the end of the structure. The set
of statements in the structure is executed again and
again until the test condition is true. If the test
condition becomes false control is transferred
outside the structure.
Example
sum = 0;
do
{
digit = n % 10;
sum = sum + digit;
n = n / 10;
}while(n>0);
FOR STATEMENT: This structure is also called the “fixed
execution” iteration structure. This is used when we
know exactly how many times a particular set of
statements is to be repeated again and again. The for
statement can be either used as the increment looping
statement or the decrement looping statement.
Syntax
for (expression 1; expression 2; expression 3)
{
Statements 1;
Statements 2;
………..
}
Statements n+1;
Example
fact = 1;
for(i=1;i<=n;i++)
fact = fact * i;
Program to find the factorial of a number using for
statement.
#include<iostream.h>
◦ #include<conio.h>
void main( )
◦ {
◦ long int fact;
◦ int num,i;
◦ clrscr();
◦ cout<<"Enter the number:"<<endl;
◦ cin>>num; fact=1;
◦ for(i=fact;i<=num;i++)
◦ {
◦ fact=fact*i;
◦ }
◦ cout<<"The factorial of a number
is:"<<fact<<endl;
◦ getch();
◦ }
1 MARK QUESTIONS
1)Name the three basic programming constructs.
2)What is sequence construct?
3)What is selection construct?
4)Mention the statements that can be implemented
using selection construct.
5)What is the other name of simple-if statement?
6)Write the syntax of simple-if statement.
7)Draw the flowchart of simple-if statement.
8)What is the other name of if-else statement?
9)Write the syntax of if-else statement.
10) Draw the flowchart of if-else statement.
11) What is meant by nested-if?
12) What is if-else-if statement also called as?
13) What is the other name of multiple selection
statement?
14) What is iteration construct?
15) What is iteration also called as?
16) Mention the statements that can be
implemented using iteration construct.
17) What is while loop also called as?
18) Write the syntax of while statement.
19) Draw the flowchart of while statement.
20) What is do-while loop also called as?
21) Write the syntax of do-while statement.
22) Draw the flowchart of do-while statement.
23) What is for loop also called as?
24) Write the syntax of for statement.
25) Draw the flowchart of for statement.
26) When is for statement used?
2 MARK QUESTIONS
1)What is selection construct? Mention the
different selection construct.
2)Write the syntax of nested-if statement.
3)Draw the flowchart of nested-if statement.
4)Write the syntax of if-else-if statement.
5)Draw the flowchart of if-else-if statement.
6)Write the syntax of multiple selection statement.
7)Draw the flowchart of multiple selection
statement.
8)What is iteration construct? Mention the different
iteration construct.
3 MARK QUESTIONS
1)Explain sequence construct.
2)Explain simple-if statement.
3)Explain if-else statement.
4)Explain if-else-if statement.
5)Explain nested-if statement.
6)Explain multiple selection statement.
7)Explain while statement.
8)Explain do-while statement.
9)Explain for statement.
5 MARK QUESTIONS
1)Explain simple-if statement with an example.
2)Explain if-else statement with an example.
3)Explain if-else-if statement with an example.
4)Explain nested-if statement with an example.
5)Explain multiple selection statement with an
example.
6)Explain while statement with an example.
7)Explain do-while statement with an example.
8)Explain for statement with an example.
❑CHARACTERISTICS OF A GOOD
PROGRAMModification
❑Reliable
❑Portable
CHARACTERISTICS OF A GOOD PROGRAM
► Modification :A good program is the one which
allows any modifications easily whenever needed.
► Easy and efficient :The logic used in the program
should always produce correct results and the
execution should be faster.
► Interactive and User friendly: The user should
have easy interactive screen and should get correct
directions and information when they are going
through the program.
► Proper documentation in code :The
documentation will help the programmer to
identify parts of the code and clarify their meaning
in the program.
► Reliable :The good program should be able to
cope up from any unexpected situations.
► Portable :The program we create should run in
different types of machines with a minimum or no
change.
TYPES OF PROGRAM ERRORS:
There are 3 types of errors.
► Syntax errors
► Semantic errors/Logical errors
► Runtime errors
SYNTAX ERROR : An error which occurs due to the
wrong use of statements in a programming language.
SEMANTIC ERROR :An error which occurs due to the
wrong use of logic.
RUNTIME ERRORS :Errors that are detected during the
execution of the program is called as runtime errors.
APPROACHES TO PROBLEM SOLVING
1.TOP DOWN ANALYSISA given problem is not solved as
a single unit, but it is broken down into small
manageable parts called as module. The top- down
approach is based on a concept called as divide and
conquer. The top- down approach is also called as
stepwise refinement or modular programming.
Top-down design involves dividing problems into
sub problems and further dividing this sub problems
into smaller sub problems until it leads to sub
problems that can be implemented as program
statements.
By subdividing the problem, you create a hierarchical
structure called a tree structure.
Example
C++ program to find the largest of three numbers
using if-else-if statement.
#include<iostream.h>
main()
{
int a,b,c,l;
cout<<“Enter the three numbers “;
cin>>a>>b>>c;
if((a>b) && (a>c))
l = a;
else if (b>c)
I = b;
else
l =c;
cout<<“The largest number is “<<l;
}
NESTED if STATEMENT: It is possible to write an if
statement within another if statement. Ii is called as
nested if.
SYNTAX
if (expression 1)
if (expression 2)
Statement 1;
else
Statement 2;
else
if (expression 3)
Statement 3;
else
Statement 4;
case 5 : cout<<“Thursday”;
break;
case 6 : cout<<“Friday”;
break;
case 7 : cout<<“Saturday”;
break;
Examples
1) for(i= 1; i <= 10; i++)
cout << i;
2) Multiple statements can be included in an
expression of the for loop by using the comma
operator.
for (sum = 0, i =1 ; i <= 10; sum = sum +i, i++);
cout << “Sum of ten natural numbers = “ << sum;
Program to print all the odd numbers up to the given
limit
#include<iostream.h>
#include<iomanip.h>
main()
{
int n,i;
cout<<“Enter the limit “;
cin>>n;
cout<<“The odd numbers are “<<endl;
for(i=1;i<=n;i=i+2)
cout<<setw(3)<<i;
}
NESTED LOOPS: If one looping statement is enclosed in
another looping statement, then such a sequence of
statements is called as nested loops.
If one ‘for’ statement is performed within another, the
sequence is called as ‘nested- loop’.
Whenever nested loops are used the inner loop is
completely enclosed by the outer loop. The inner loop
is completely repeated for each repetition of the outer
loop.
Example
for(row=1; row<=3;row++)
{
for(column=1; column <=3; column++)
cout << column<<setw(4);
cout << endl;
}
The output generated will be 123
123
123
1 MARK QUESTIONS
1)What is iteration?
2)What is iteration also called as?
3)What is while loop also called as?
4)Write the syntax of while loop.
5)Draw the flowchart of while loop.
6)What is do-while loop also called as?
7)Write the syntax of do-while statement.
8)Draw the flowchart of do-while statement.
9)Write any one difference between while and
do-while loop.
10) What is for loop also called as?
11) Write the syntax of for statement.
12) Draw the flowchart of for statement.
13) What is meant nested loop?
5 MARK QUESTIONS
1)Explain while statement with an example.
2)Explain do-while statement with an example.
3)Compare while and do-while statements.
4)Explain for statement with an example.
JUMP STATEMENTS
The jump statements unconditionally transfer program
control within a program.
C++ has four statements that perform an unconditional
branching- goto, return, break and continue.
goto and return statements are used anywhere in the
program whereas break and continue are used inside
the loops.
BREAK STATEMENT: The break statement is used to
terminate a case in the switch statement or to
terminate the loops. When ‘break’ is encountered
inside any loop, control automatically passes to the first
statement after the loop.
The break statement is written as break;
Example
for(n=0;n<100;n++)
{
cout<<n;
if(n == 10)
break;
}
The above program segment prints the numbers
from 0 – 10. Then the loop terminates because ‘break’
causes immediate exit from the loop.
CONTINUE STATEMENT: When the keyword ‘continue’
is encountered inside any loop, control automatically
passes to beginning of the loop.
The ‘continue’ statement is written as: continue;
Example
for(n= 5; n>0 ; n--)
{
if (n = = 3)
continue;
cout<<setw(3)<<n;
}
The above program segment prints the
numbers 5 4 2 1. Here, when the ‘n’ value reaches 3
control is transferred to the beginning of the loop.
RETURN STATEMENT: The ‘return’ statement is used to
return from a function.
GOTO STATEMENT: The ‘goto’ statement is used to
transfer control from one point in a program to any
other point in that program. This action is called
branching.
SYNTAX
goto labelname;
…………….
………….....
labelname : statement;
labelname is a user defined identifier and can
appear either before or after ‘goto’. This statement
provides an unconditional jump to the statement
indicated by the labelname. No declaration is required
for the labelname.
Write a C++ program to print the numbers from 10 to
1 using goto statement:
#include<iostream.h>
#include <iomanip.h>
main()
{
int n = 10;
loop : cout<<setw(3)<<n;
n- -;
if(n>0)
goto loop;
}
exit() FUNCTION: exit() function is used to terminate
the execution of the program.‘break’ statement
terminates the execution of the loop in which it is
written, where as exit() terminates the execution of the
program itself.
1 MARK QUESTIONS
1)What is the purpose of ‘jump’ statements?
2)Mention the different ‘jump’ statements.
3)What is the purpose of the ‘jump’ statement?
4)What is the purpose of the ‘continue’ statements?
5)What is the purpose of the ‘return’ statements?
6)What is the purpose of the ‘goto’ statements?
7)What is the purpose of the exit() function?
8)What is the difference between break and exit()?
9)What is the difference between break and
continue?
10) Write the syntax of goto statement.
5 MARK QUESTIONS
1)Explain ‘jump’ statements.
ARRAYS
Normal variable can store a value. We need arrays to
store a large number of elements under a single
name. This makes the accessing of elements easier.
Array:
An array is an ordered collection of elements of same
data type that share common name.
Index
The elements of the array are stored in
consecutive memory locations and are referenced
by a number called an index or a subscript.
Subscript/index indicates the position of the
element in the array. The index is used to access
the individual element. Array subscript starts with
0.
The method of numbering the i th element with index
i-1 is called zero based indexing. For example, the
element a[3] is 3 steps from the element a[0].
Types Of Arrays
There are three types of arrays.
1) One-dimensional array
A collection of elements, all of the same type and
name, structured in one dimension. Each element is
accessed by an index that indicates the component’s
position within the collection.
2) Two-dimensional array
A collection of elements, all of the same type and
name, structured in two dimensions. Each element is
accessed by a pair of indices that represent the
element’s position in each dimension.
3) Multi-dimensional array
A collection of elements, all of the same type and
name, structured in N dimensions(N≥1). Each element
is accessed by N indices, each of which represents the
element’s position within that dimension.
One-dimensional array
A collection of elements, all of the same type and
name, structured in one dimension. Each element is
accessed by an index that indicates the component’s
position within the collection.
The general form of array declaration is
datatype arrayname[size];
where ‘datatype’ describes what type of data
is stored in the array, ‘size’ specifies the number of
elements in the array and must have a value greater
than 0 and ‘arrayname’ identifies the array.
Example
int marks[80];
declares an array named ‘marks’ to store 80
integer elements.
Initialization of one dimensional array:
You can give the values to each array elements when
the array is declared.
Example 1
int a[5]={9,1,6,2,8};
In the above example, value 9 is stored in
a[0],1 in a[1],6 in a[2],2 in a[3],8 in a[4].
If there are less number of elements specified than
the size of the array ,the remaining elements are filled
with 0 by the compiler.
Example 2
float weight[5]={1.5,2.8,2.5};
In the above example value 1.5 is stored
in weight[0],value 2.8 in weight[1],and 2.5 is stored in
weight[2].The elements weight[3],weight [4] are
initialized with 0.Thus in the initialization, the default
value is 0.
When an array has an explicit initialization ,its size can
be omitted from the declaration.
Example 3
int a[5]={9,-5,6,2,8};
is equivalent to int a[ ]={9,-5,6,2,8};
The amount of space required to hold an array is
directly related to its type and size of the array. The
total size can be calculated using
Total size = size of data type * size of array
Example
Consider the declaration int A[4];
Total size = 2 * 4 = 8
C++ program to read the elements into the array and
printing the elements
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
void main()
{
int a[10],i,n;
clrscr();
cout<<“Enter the number of elements ”;
cin>>n;
cout<<“Enter the elements ”;
for(i=0;i<n;i++)
cin>>a[i];
cout<<“The elements are ”;
for(i=0;i<n;i++)
cout<<setw(5)<<a[i];
getch();
}
Two-dimensional array
A collection of elements, all of the same type
and name, structured in two dimensions. Each element
is accessed by a pair of indices that represent the
element’s position in each dimension.
The elements of two-dimensional arrays are
represented as rows and columns. To identify any
element, we should know its row number and column
number.
The general form of array declaration is
datatype arrayname[row-size] [column-size];
where ‘datatype’ describes what type of data is
stored in the array, ‘row-size’ specifies the number of
rows, ‘column-size’ specifies the number of columns in
the array and must have a value greater than 0 and
‘arrayname’ identifies the array. The row-size and
column-size should be separately enclosed within
square brackets.
Example
int A[8][2];
declares an array named ‘A’ to store 16(8x2) integer
elements. The elements are arranged as 8 rows and 2
columns.
Initialization of TWO dimensional array
We can initialize a two dimensional array either by
initializing it in its declaration or by using assignment
statement.
Example 1
int a[2][3]={10,9,1,6,2,8};
Array ‘a’ contains 2 rows and 3 columns.
a[0][0]=10 a[0][1]=9 a[0][2]=1
a[1][0]=6 a[1][1]=2 a[1][2]=8
Example 2
int a[2][3]={
{4,9},
{1}
};
Array ‘a’ contains 2 rows and 3 columns. We
initialize the first two elements to the first row, the next
element to the second row. The remaining elements
are automatically set to zero.
a[0][0]=4 a[0][1]=9 a[0][2]=0
a[1][0]=1 a[1][1]=0 a[1][2]=0
Example 3
int a[2][3]={ {0},{0}};
Array ‘a’ contains 2 rows and 3 columns. All the
elements are automatically set to zero.
a[0][0]=0 a[0][1]=0 a[0][2]=0
a[1][0]=0 a[1][1]=0 a[1][2]=0
Accessing the elements
We need to use nested for loops. One loop
processes the rows and another loop processes the
columns. If outer loop is for rows and inner loop is for
columns, then for each row index, all the columns are
processed and then the same process is repeated for
next row index.
C++ program to read the elements into the array and
printing the elements
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
void main()
{
int a[10][10],i,n,m;
clrscr();
cout<<“Enter the order of the matrix ”;
cin>>m>>n;
cout<<“Enter the elements ”;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
cin>>a[i][j];
}
cout<<“The elements are ”;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
cout<<setw(5)<<a[i][j];
cout<<endl;
}
getch();
}
Multi-dimensional array
A collection of elements, all of the same type and
name, structured in N dimensions(N≥1). Each element
is accessed by N indices, each of which represents the
element’s position within that dimension.
The general form of array declaration is
datatype arrayname[s1][s2] ……..[sn];
where si is the size in the ith dimension.
1 MARK QUESTIONS
4) strcmp() function
This function is used to alphabetically compare a
string with another string. This function is case
sensitive(it treats the uppercase letters and lowercase
letters as different).
Syntax
strcmp(string1, string2);
It compares all the characters of string2 with
string1. It returns 0 if the two strings are equal, a
positive value if string1 > string2, a negative value if
string1 < string2.
Example
char str1[5] = “PCMC”;
char str2[5] = “PCMC”;
strcmp(str1, str2); returns 0.
5) strcmpi() function
This function is used to alphabetically compare a
string with another string. This function is not case
sensitive(it treats the uppercase letters and lowercase
letters as same).
Syntax
strcmpi(string1, string2);
It compares all the characters of string2 with
string1. It returns 0 if the two strings are equal, a
positive value if string1 > string2, a negative value if
string1 < string2.
Example
char str1[5] = “PCMC”;
char str2[5] = “pcmc”;
strcmpi(str1, str2); returns 0.
6) strrev() function
It converts a string into its reverse.
Syntax
strrev(string);
Example
char str[5]= “PCMC”;
strrev(str) returns “PCMC” into “CMCP”.
7) strlwr() function
It converts a string into lowercase.
Syntax
strlwr(string);
Example
char str[4]= “PCMC”
strlwr(str) returns “PCMC” into “pcmc”.
8) strupr() function
It converts a string into uppercase.
Syntax
strupr(string);
Example
char str[4]= “pcmc”
strupr(str) returns “pcmc” into “PCMC”.
Inputting a string
The function getline() is used to read a string.
Syntax
cin.getline(string, size);
Example
cin.getline(str, 30);
Outputting a string
The function write() is used to output a string.
Syntax
cout.write(string, size);
Example
cout.write(str, 30);
2 MARK QUESTIONS
1)What is a function? Mention the types of
functions.
2)What is a header file? Mention few header files.
3)Explain any two character functions.
4)What is the difference between isupper() and
islower()?
5)What is the difference between isupper() and
toupper()?
6)What is the difference between islower() and
tolower()?
7)What is a string? Mention the header file that
should be included to manipulate strings.
8)What is a string? Write the syntax of declaration.
9)Explain the syntax of declaring a string with an
example.
10) Explain any two string functions.
11) Explain strlen() function.
12) Explain strcat() function.
13) Explain strcpy() function.
14) Explain strcmp() function.
15) Explain strcmpi() function.
16) What is the difference between strcmp() and
strcmpi() functions?
17) Explain strrev() function.
18) Explain strlwr() function.
19) Explain strupr() function.
20) What is the difference between strlwr() and
strupr() functions?
21) What is the difference between strcat() and
strcpy() functions?
22) What is the difference between strcmp() and
strcat() functions?
23) What is the difference between strcmp() and
strcpy() functions?
24) Write the syntax of inputting and outputting a
string?
25) Write the syntax of inputting and outputting a
single character?
26) Explain the syntax of inputting a string.
27) Explain the syntax of outputting a string.
28) Explain the syntax of inputting a single character.
29) Explain the syntax of outputting a single
character.
⮚ return_type_specifier function_name(argumentlist
with declaration) -> Function header
⮚{
⮚ Executable-statement 1;
⮚ Executable-statement 2;
⮚ Executable-statement 3;
Body of the function
⮚ -------
⮚ ------
⮚ Executable-statement n;
⮚ return (expression);
-----
}
1 MARK QUESTIONS
1)What is user defined function?
2)Write one advantage of user defined function.
3)Mention the datatype used when the function
return no value to the calling function.
4)What is meant by calling function?
5)What is meant by called function?
6)What is meant by function call?
7)Write the general form of function call.
8)Write the general form of ‘return’ statement.
9)Write the general form of main() function.
10) What is function prototype?
11) Write the general form of the function
prototype.
12) What is actual argument?
13) What is formal argument?
14) What are local variables?
15) What are global variables?
5 MARK QUESTIONS
1)Write the advantages of user defined function.
2)Explain the structure of a user defined function
with an example.
⮚ Recursive functions.
}
#include<iostream.h>
void main()
{
int sumoften();
s=sumoften( );
cout<<“Sum=“<<s;
}
int sumoften()
{
int sum=0,i;
for(i=0;i<10 ; i++)
sum= sum + i;
return (sum);
}
Function with arguments and with return values
In this method, the function receives some arguments
but returns a value.
Syntax
return_type_specifier function name
(argument_list with declaration)
{
statements;
return (value/variable /expression);
}
Example
int sumoftwo(int c, int d)
{
int s;
s = c + d;
return(s);
}
Recursive functions
A function that calls itself is called recursive function .
The process of calling a function by itself is called as
recursion.
Recursive functions must have one or more terminating
conditions to terminate recursion otherwise recursion
will become infinite.
Syntax
return type specifier function_name (argument list)
{
statements;
return (function name (arguments));
}
1 MARK QUESTIONS:
1)Write the syntax of function with no argument and
no return values.
2)Write the syntax of function with argument and no
return values.
3)Write the syntax of function with argument and
with return values.
4)Write the syntax of function with no argument and
with return values.
5)Write the syntax of recursive functions.
6)What is recursion?
7)What is recursive function?
3 MARK QUESTIONS
1)Explain the syntax of function with no argument
and no return values with an example.
2)Explain the syntax of function with argument and
no return values with an example.
3)Explain the syntax of function with argument and
with return values with an example.
4)Explain the syntax of function with no argument
and with return values with an example.
5)Explain recursive functions with an example.
Scope of variables:
Scope of variables refers to the part of the
program where the value of the variables can be
used .
Passing default arguments to functions
To call a function we need not pass the values of
the arguments to a function from the calling
function . Default values can be assigned to the
formal arguments which does not have a matching
arguments in the function call. It can be assigned
only in the function prototype.
Example
float si (float p, int t ,float r=1.2);
1.2 is the default value provided to the argument
‘r’ .The function call can be S= si (1000,2);
Default arguments are used when a matching
argument is missing in the function call statement.
Any argument in the prototype cannot have a
default value. An argument in a prototype can
have default value if and only if all arguments
appearing on its right have default values .Default
values should be added from right to left.
Example :float si ( float p, int t=2,float r=1.2);
Uses of default arguments:
Example:
student s;
‘s’ is a structure variable of type ‘student’.
The definition and the declaration of a structure can
be combined.
Example:
struct student
{
int regno;
char name[20];
char class[10];
char comb[6];
float percentage, fees;
}s;
NOTE
1. The definition of a structure does not reserve
memory space to store values for the structure.
Definition just defines a form of the structure.
❑ Abiword.
❑Apple TextEdit.
❑Word perfect.
❑Microsoft Word.,etc
❖File Menu .
❖Edit Menu .
❖View Menu .
❖Insert Menu .
❖Format Menu .
❖Window menu .
SPREADSHEETS
An electronic spreadsheet is a computer application
program that can also hold formulas in a cell that serve
as a calculator. It performs calculations more accurately
and faster compared to manual calculations.
ESS document is a worksheet. Several worksheets make
up a workbook. The files with .xls or .xlsx extensions
identifies a workbook. ESS has rows numbered from 1
to 1048576 and columns represented from A to XFD.
Spreadsheets Applications:
▪ The ESS is the best tool for all the text and
calculations involved applications.
MENUS:
File Menu:
In file menu we have options like:-
▪ Undo editing(Ctrl+Z)
▪ Cut(Ctrl+X)
▪ Copy(Ctrl+C)
▪ Paste(Ctrl+V).
❖ Electronic mail
❖ Voice mail
❖ Chat
❖ Newsgroup
❖ Search engines
❖ E-Commerce
1) ELECTRONIC MAIL(EMAIL)
It is the transmission of messages over a
communication network.
ADVANTAGES OF ELECTRONIC MAIL
1)Messages can be sent at whatever time of day .
2)Messages will be in the recipient’s mailbox within
minutes.
3)No need to speak to the recipient person.
4)Delivery of messages can be confirmed.
5)Copies can be sent automatically to everyone.
6)Mails are saved in the inbox. These can be viewed
later.
7) Mails can be used as an advertising tool.
8) It reduces the volume of paper that is to be
processed.
9) It is the cheapest and best communication service.
10) Mails can be accessed globally and any time.
DRAWBACKS OF ELECTRONIC MAIL
1)Recipient must also be electronic mail users.
2)Until a mailbox is checked, there is no way of
knowing that a message has arrived.
3)There is occasional use of junk mail.
4)Viruses are transmitted through email and have
the potential to harm the computer systems.
5)Emails can be hacked.
2) VOICE MAIL: Voice-mail or voice message is a
computer based system that allows users to exchange
personal voice messages.
3) TELNET OR REMOTE LOGIN: Telnet permits your
computer to log onto another computer at some other
location and use it as if you were there.
4) CHAT: It is exchange of text between the computers.
Conversion is fast and interactive.
5) NEWSGROUP:Newsgroups are discussion groups on
internet. A user can send a message to the newsgroup.
Other users can read this message from this site and
reply.
6) FILE TRANSFER PROTOCOL: FTP is used to transfer
files on internet easily and quickly.
7) SEARCH ENGINES: These are used to search the
desired information based on text, domain name etc. It
displays the related site names which are matching
with the text or domain name. Example :- google,
gopher etc.
8) E-COMMERCE: Trading of goods or services through
internet is called as E-commerce.
OR
Electronic Commerce is the practice of conducting
business transactions online.
SOME TERMS RELATED TO WEB:
World Wide Web(WWW): It is a system of interlinked,
hypertext documents that runs over the internet.
Web page: It is a resource of information. It may
contain text, pictures, audio or video data.
Web Site: It is a collection of web pages.
Web browser: It is a software application that enables
a user to display and interact with the information
located on a web page or a web site. Some of the web
browsers are Internet Explorer, Mozilla Firefox, Google
Chrome.
HyperText Markup Language
HTML is the markup language for the creation of web
pages.
Hyper Text Transfer Protocol(HTTP)
It is a set of standards that allow users of the world
wide web to exchange information found on web
pages.
Transmission Control Protocol/Internet Protocol
TCP/IP provides the rules for communicating over the
internet.
Uniform Resource LocatorIt is also known as web
address .It is a specific character string that constitutes
a reference to a resource.
Example: ”http
://www.example.org/college/main.html”.
Domain name
A name that identifies a computer or computers on
the internet. These names appear as a component of a
Web site’s URL. This type of domain is also called a
hostname.
Example.www.computer.org
Surfing
Process of searching information by hopping from one
server to another in the internet is called as surfing.
HTML: Hyper text markup language is the markup
language, which is popularly used in the World Wide
Web. Tim Berners Lee developed it in 1989. A HTML
document can include text, pictures and links to other
related information or documents.
The tools which will help us in the process of creating
a HTML document are :
1)A Text Editor
2)A Web Browser
3)A Graphics Software
4)A Web Server
HTML tags consist of a left angle bracket(<), a tag
name, and a right angle bracket(>).Tags are paired to
start and end the tag instruction.
Example :- <html> and </html>
The end tag looks like the start tag except a slash(/)
precedes the text within the brackets.
HTML is not case sensitive.<HTML> is equivalent to
<Html>.
A html document:
Every HTML document contains two sections a head
section and a body section. The head section contains
the title, and the body contains the actual text that is
made up of paragraphs, lists, and other elements.
<Html>
<Head>
<Title>_________________________</title>
</Head>
<Body>
_______________________________
_______________________________
</Body>
</Html>
EXECUTING A HTML PROGRAM:
The first step in creating a HTML document is to write
the code in a text editor. The commonly used text
editor is notepad. Notepad can be opened as
start -> programs -> accessories -> notepad
Once notepad is opened the code can be typed in it
and then the code has to be saved using the extension
.html.
To view the created html document we will have to use
a web browser such as internet explorer.
Once the internet explorer window is opened click
File -> open to open the html document that was saved
for viewing.
To make modifications in the html code, select
View -> source. This will bring the notepad for use.
After making the necessary modifications the file
should be saved. Go back to internet explorer and click
on the refresh button. The modified page will be
displayed.
Some markup tags:
HTML: This element tells your browser that the file
contains HTML coded information.
HEAD: The head element identifies the first part of
HTML coded document that contains the title.
TITLE: The title element contains your document title.
The title is displayed in the title bar at the top of the
browser window.
BODY: The second and the largest part of your HTML
document is the body, which contains the content of
your document.
Headings: HTML has six levels of headings, numbered 1
through 6, with 1 being the largest. Headings are
displayed in larger or bolder fonts than normal body
text. The first heading in each document should be
tagged <H1>.
The syntax is <Hy> text of heading </Hy>
where ‘y’ is a number between 1 and 6 specifying the
level of heading. Do not skip levels of headings in your
document.
PARAGRAPHS: You must indicate paragraphs with <P>
elements. Without <P> elements, the document
becomes one large paragraph. The </P> closing tag
may be omitted. This is because browsers understand
that when they encounter a <P> tag, it means that the
previous paragraph has ended.
Some Tags Used For Text Formatting
Big:
If a particular text matter is to be displayed in a font
slightly bigger than the regular font then the tag <BIG>
may be used.
<Big> text to be displayed </big>
Small:
If a particular text matter is to be displayed in a font
slightly smaller than the regular font then the tag
<SMALL> may be used.
<Small> text to be displayed </small>
Font:
This tag is used to specify the font style, color and size
of the character or word or text under consideration. A
number of attributes can be considered for this tag.
A) Font Face
This attribute is use to change the font style. The name
of the font has to be identified as a value enclosed in
double quotes. If the attribute is not specified then the
default font is assumed.
B) Font Size
The size attribute indicates the size with which the data
is to be displayed.
C) Font Color
This attribute allows the user to change the color of the
text being is displayed.
Bold: This tag is used to display the data in a thicker
and darker manner.
<B> text to be displayed </b>
Italics: This tag is used to display the data in italics.
<I> text to be displayed </i>
Underline: This tag is used to display the data with an
underline below it.
<U> text to be displayed </u>
Center: This tag is used to display the data in the center
of the line.
<Center> text to be displayed </center>
Marquee: The text which is included between this tag
will scroll from one end of the document to the other
as required.
<Marquee direction = “right”> text </marquee>
Background color: The background color of a page can
be changed. This attribute is one of the attributes of
the <BODY> tag.
<Body text =“blue” bgcolor = “green”>____________
</body>
Line breaks: The <BR> tag forces a line break. The next
output will be generated from a new line.
Lists:
A list is used to display a collection of items in a
particular form. HTML supports three types of lists.
They are unnumbered, numbered and definition lists. It
is also possible to use nested lists.
Unnumbered lists
To make an unnumbered, bulleted lists
1)Start with an opening list <UL> tag
2)Enter the <LI> tag followed by the individual item;
no closing tag </LI> is needed.
3)End the entire list with a closing list </ul> tag.
<UL>
<LI> red
<LI> blue
<LI> green
</UL>
Numbered lists: A numbered list is also called as
ordered list. It uses <OL> instead of <UL>. The items are
tagged using the same<li> tag.
<OL>
<LI> red
<LI> blue
<LI> green
</OL>
NESTED LISTS:
Lists can be nested.
<Ul>
<Li> C programs
<Ul>
<Li> To find the factorial
<Li> To find the Fibonacci number
</Ul>
<Li> HTML programs
<Ul>
<Li> To create a web page
<Li> To create a web site
</Ul>
</Ul>
LINKING: HTML can link text and/or an image to
another document or section of a document. A
browser highlights the identified text or image with
color and underlines to indicate that it is a hypertext
link or hyperlink or link. Html’s single hypertext-related
tag is <a>, which stands for anchor.
To include an anchor in your document :
1)Start the anchor with <a(include a space after the
A)
2) specify the document you are linking to by
entering the parameter href=“filename” followed
by a closing right angle bracket(>)
3) Enter the text that will serve as the hypertext link
in the current document.
4) Enter the ending anchor tag</a>(no space is
needed before the end anchor tag)
<A href=“file2.html”>name</A>
This make the word name the hyperlink to the
document file2.Html, which is in the same directory as
the first document.
INLINE IMAGES:
To include an inline image enter
<IMG src = imagename>
Where SRC stands for source and imagename is the
URL of the image file. If the image file is stored on the
hard disk then the complete path along with the
filename should be included. If an URL address is
included then the file will be displayed only if there is
an internet connection.
5 MARK QUESTIONS
1)Explain internet services.
2)Write the advantages of e-mail.
3)Write the disadvantages of e-mail.
4)Explain any five HTML tags.