Hsslive Pyq Cs Xi
Hsslive Pyq Cs Xi
in ®
Chapter 1
The Discipline of Computing
2. Name the ancient number system with the largest base. Score 1
Sumerian / Babylonian
Generations of computers
1. Write short note on First Generation Computers. Score 2
First Generation Computers were built using vacuum tubes. Stored program concept was
implemented. The input was based on punched cards and paper tapes. The output was displayed on
printouts.
Example : ENIAC, EDVAC, UNIVAC
2. Draw the block diagram of John Von Neumann's computer architecture. Score 2
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®
3. Briefly explain about First, Second and Fifth generations of computers. Score 3
First Generation Computers were built using vacuum tubes. Stored program concept was
implemented. The input was based on punched cards and paper tapes. The output was displayed on
printouts.
Second Generation Computers were built using transistors. They were smaller, more
powerful and faster. They required less electricity, emitted less heat and less expensive too.
Fifth generation computers are based on Artificial Intelligence (AI). They are used in some
applications such as speech recognition, face recognition, robotic vision etc. The two most common
AI programming languages are LIST and Prolog.
Evolution of computing
1. Who is known as the father of Modern Computer Science? Score 1
Alan Turing
2. Who is known as the Father of Computer Science as well as Artificial Intelligence ? Score 1
Alan Turing
-----------------------------------------------------------------------------------------------------------------------
Chapter 2
Data Representation and Boolean Algebra
Number Systems
1. Number of symbols in a number system is called ………………. 1
Base
Number Conversions
1. The number (158)10 can be represented in hexadecimal number system as ………. 1
16 158
16 9 14 (E)
0 9
Ans. (9E)16
3. Convert
a. (234)10 to binary
b. (1234)10 to Hexadecimal 3
a.
2 234
2 117 0
2 58 1
2 29 0
2 14 1
27 0
23 1
21 1
0 1
Ans. (11101010)2
b.
16 1234
16 77 2
16 4 13 (D)
0 4
Ans. (4D2)16
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®
2 28
2 14 0
27 0
23 1
21 1
0 1
Ans. (11100)2
8 1234
8 154 2
8 19 2
82 3
0 2
Ans. (2322)8
11001 = 1 x 24 + 1 x 23+ 0 x 22 + 1 x 21 + 1 x 20
= 1 x 16 + 1 x 8 + 0 + 0+ 1 x 1
= 16 + 8 + 1
= (25)10
Ans. (25)10
Ans. (11)10
Ans. (27)10
Ans. (4)10
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®
34 = 3 x 81 + 4 x 80
=3x8+4X1
= 24 + 4
= 28
Ans. (28)10
1 6 4
001 110 100
Ans. (001110100)2
A B
1010 1011
Ans. (10101011)2
A C
1010 1100
Ans. (10101100)2
F
1111
Ans. (1111)2
Ans. (5A)16
11011 = 1 x 24 + 1 x 23 + 0 x 22 + 1 x 21 + 1 x 20
= 1 x 16 + 1 x 8 + 0 + 1 x 2 + 1 x 1
= 16 + 8 + 0 + 2 + 1
= (27)10
5 0 7
101 000 111
(101000111)2
iii) (100)10
iv) (10)16 3
Data Representation
1. What is Sign Magnitude Representation? Represent 100 in that form. 3
In this method, MSB is used for representing sign of integer. Remaining 7 bits are used for
representing magnetude of integer.
2 100
For negative numbers sign bit is 1 and for positive numbers sign bit is 0.
2 50 0
2 25 0
100
2 12 1
Number is positive, so MSB is 0.
26 0
7 bit binary equivalent of 100 = 1100100
23 0
100 = (01100100)2 21 1
0 1
2. Represent the following integers in sign and magnetude, 1s complement and 2s complement form.
a) +25
b) -30 3
a) + 25
Sign & Magnetude
Number is positive, so MSB is 0.
7 bit binary equivalent of 25 = 0011001
25 = (00011001)2
1’s Compliment
Binary of 25 in 8 bit form = 00011001
25 in 1’s compliment form = (00011001)2
2’s complement
Binary of 28 in 8 bit form = 00011001
25 in 2’s complement form = (00011001)2
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®
b) -30
Sign & Magnetude
Number is negative, so MSB is 1
7 bit binary equivalent of 30 = 0011110
-30 = (10011110)2
1’s Compliment
Binary of 30 in 8 bit form = 00011110
30 in 1’s compliment form = (11100001)2
2’s complement
Binary of 30 in 8 bit form = 00011110
30 in 2’s complement form = 11100001 +
1
(11100010)2
2’s complement
Binary of 78 in 8 bit form = 01001110
78 in 2’s complement form = 10110001 +
1
(10110010)2
2’s complement
Binary of 38 in 8 bit form = 00100110
38 in 2’s complement form = 11011001+
1
(11011010)2
ii. EBCDIC
It stands for Extended Binary Coded Decimal Interchange Code. It is an 8 bit code. It can represent
256 characters.
Iii. UNICODE
Unicode is a 16 bit code. So it can represent 65536 characters. Unicode can represent characters in
almost all written languages of the world.
Symbol
AND
The logical gate that performs logical AND operation is called logical AND Gate.
Symbol
Truth Table
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®
NOT
The logical gate that performs logical negation is called logical NOT Gate. It is also called
inverter.
De Morgan’s Theorems
1. State De'Morgan's theorems. 2
a. The complement of sum of Boolean variables is equal to product of their individual components.
b. The complement of product of Boolean variables is equal to sum of their individual components.
Universal Gates
1. What are universal gates in Boolean algebra? Draw its symbols. 3
A universal gate is a gate which can implement any Boolean function without using any other
gate type. The NAND and NOR gates are universal gates in Boolean Algebra.
NAND gate
NAND gate is an inverted AND gate.
NOR gate
NOR gate is an inverted OR gate.
-----------------------------------------------------------------------------------------------------------------------
Chapter 3
Components of the Computer System
Hardware
1. Tangible and visible parts of computer is known as ________. 1
Hardware
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®
RAM ROM
Faster than ROM Slower memory
Stores Operating System, application programs Stores BIOS
and data while computer is ON
read/write memory Read only memory
Volatile Non volatile
9. Small and fast memory between processor and RAM is called ……….. 1
Cache memory
11. Write the following memory devices in the order of their speed. 1
i) cache ii) RAM iii) Hard Disk iv) Registers
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®
12. Rearrange the following memories in descending order depending on their speed. 2
Hard disk, RAM, Cache Memory, Registers
1. Primary Memory
Primary Memory is a semiconductor memory that is accessed directly by the CPU.
There are three types of primary memory.
a. Random Access Memory (RAM) - RAM refers to the main memory that microprocessor
can read from and write into. It is a volatile memory.
b. Read Only Memory (ROM) - ROM is a permanent memory that can perform only read
operations. ROM is non volatile.
c. Cache Memory - It is a small and fast memory between processor and RAM. Frequently
accessed data, Instructions and intermediate results etc are stored in cache.
2. Secondary Memory
Secondary memory is permanent in nature. It is larger than RAM, but slower. The secondary
memories are
a. Magnetic Memory – It uses plastic tape / plastic disks coated with magnetic materials.
Example – Magnetic Tape, Hard Disk
b. Optical Memory – It consists of an aluminum foil sandwiched between two circular plastic
disks. It uses low-powered laser beam to read and write data.
Example – CD, DVD, Blu-Ray
c. Semiconductor Memory – It uses EEPROM chips for data storage. They do not contain any
moving parts, so they are shock proof.
14. Write the following memory devices in the order of their speed. (Fastest to slowest order) : 2
(a) Cache (b) RAM (c) Hard Disk (d) Registers
e-Waste
1. How e-Waste create environmental and health problems? 1
e-waste contains toxic substances such as mercury, lead etc which cause cancer and many other
health problems if not properly managed.
2. Define the term E-waste. Explain briefly about any two E-waste disposal methods. 3
e-Waste refers to electronic products nearing the end of their "useful life".
Reuse – It refers to second hand use or usage after modification or upgradation.
Recycling - It is the process of manufacturing new products from e-waste.
4. Which among the following is NOT a recommended method for e-waste disposal? 1
a) Reuse b) Incineration c) Land Filling d) Recycling
c) Land filling
Software
1. What is Operating System? Give two examples. 1
Operating System is a set of programs that acts as an interface between user and
hardware. It controls and co-ordinates the operations of the computer.
Ex. Microsoft Windows, Linux, Ubuntu, DOS
4. Name two different language processors which translate high level language program into
machine language program. 1
Compiler, Interpreter
a. Operating System
It is a set of programs that acts as an interface between user and hardware. It controls and
co-ordinates the operations of the computer.
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®
b. Language Processors.
Language Processors translate programs written in Assembly Language or High Level
Language into Machine Language.
Different types of Language Processors are
Assembler
Compiler
Interpreter
c. Utility Software
Set of programs which help users in system maintenance tasks.
Different types of Utility Softwares are
Compression tools
Disk Defragmenter
Backup Software
Antivirus software
12. Categorize the software given below into operating system, application package, and utility program.
Linux, OpenOffice Calc, Windows, WinZip, Kaspersky, OpenOffice Writer 2
15. Which one of the following is NOT a free and open source software. 1
a) GNU/Linux b) MS Office c) GIMP d) Mozilla Firefox
b) MS Office
a. RAM - RAM refers to the main memory that microprocessor can read from and write into. It
is a volatile memory.
b. QR code reader - Used to read QR codes as well as Bar codes.
c. 3-D Printer – Used to print 3D objects.
d. Operating System - It is a set of programs that acts as an interface between user and hardware.
It controls and co-ordinates the operations of the computer.
e. Open Source Software – Free and Open Source Software gives the user the freedom to use,
copy, distribute, examine, change and improve the software.
--------------------------------------------------------------------------------------------------------------------
Chapter 4
Principles of Programming and Problem Solving
Phases in Programming
1. Name the steps involved in problem solving. 2
or
2. What are the different phases in programming? 3
a. Problem Identification
b. Preparing Algorithm and Flowchart
c. Program coding
d. Translation
e. Debugging
f. Execution and Testing
g. Documentation
------------------------------------------------------------------------------
Algorithm
1. What is an algorithm? 1
Finite sequence of instructions to solve a problem.
Step 4 : Avg=Sum/3
Step 5 : Print Sum, Avg
Step 6 : Stop
Flowchart
1. Pick the odd one out and give a reason for your finding. 1
Answer is c)
It has one entry flow and two exit flows. All others have one entry flow and one exit flow.
Start
Input A,B,C
Avg=(A+B+C)/3
Print Avg
Stop
Start
Input L,B
Area=L* B
Print Area
Stop
7. Draw the flowchart to find the sum and average of three numbers. 3
Start
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®
Input A,B,C
Sum=A+B+C
Avg=Sum/3
Stop
Start
Input N
Is Yes
N%2=0 Print “Even”
?
No
Print “Odd”
Stop
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®
10. Draw a flowchart to check whether the given number is positive, negative or zero. 2
Start
Input N
Is Yes
N>0 Print “Positive”
?
No
Is
N>0 Yes
Print “Negative”
?
No
Print “Zero”
Stop
11. Use the proper symbols to complete the flowchart given below
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®
Start
Input H1, H2
Is Yes
H1>H2 Print H1
?
No
Print H2
Stop
b) When we implement the above algorithm in C++, what will be the output? 3
a)
b) 1 2 3 4 5 6 7 8 9 10
15. Classify the following loops into entry controlled loop and exit controlled loop for loop, while loop,
do while loop. 2
Entry Controlled Loop - for loop, while loop
Exit controlled loop - do while loop
Program Coding
1. Program written in HLL is known as .......… 1
Source code
Debugging
1. The process of correcting errors in program is called ________. 1
Debugging
Answer is d)
Documentation
1. Which phase in programming contains preparation of user, system manual and writing comments
in program. 1
Documentation
hard copy documents that contain functioning of the system, its requirements etc.
3. Some of the components in the phases of programming are given below. Write them in order of their
occurrence :
(i) Translation (ii) Documentation (iii) Problem identification (iv) Coding of program
(iii) Problem identification (iv) Coding of program (i) Translation (ii) Documentation
--------------------------------------------------------------------------------------------------------------------------
Chapter 5
Introduction to C++ Programming
Character Set
1. Write short note on character set of C++. 2
A character represents any letter, digit or any other symbol. The set of valid characters in a
language is known as its character set.
The character set of C++ are
a. Letters - A-z, a-z
b. Digits - 0-9
c. Special Characters - +,*,(,) etc
d. White spaces – Space bar, Tab
e. Other Characters – any of the 256 ASCII characters
Tokens
1. Fundamental building blocks of the program is called ________. 1
Tokens
e. Punctuatore – Special symbol that have syntactic or semantic meaning to the compiler.
Example : #, ;
cout – identifier
<< - Operator
“The Missile Man” - Literal
; - Punctuator
Identifiers
1. Write the rules followed for naming an identifier. 2
Should includes only letters, digits and underscores.
First character must be a letter or underscore.
White space and special characters are not allowed.
Keywords can not be used.
Uppercase and lowercase letters are treated differently.
4. Identify the invalid identifiers from the following and write reason for that :
A20bc, if, 5sum, adm_no, student age, classno 3
if - Keyword
5sum - First character is digit
student age - Space is not allowed
Literals
1. What is meant by Literals in C++ ? Explain its types.
Data items that never change their value during the program run is called literals.
Literals are divided in to four types. They are
a. Integer Literals – whole numbers without fractional part. Eg.100
b. Floating point Literals – Numbers with fractional part. Eg. 3.14
c. Character Literals – A character within single quotes. Eg. ‘A’, ‘9’
d. String Literals – A sequence of one or more characters within double quotes.
Eg. “ABC”, “100”
String literal - A sequence of one or more characters enclosed within a pair of double quotes.
Example - “123”, “Hello friends”
-------------------------------------------------------------------------------------------------------------------------------
Chapter 6
Data Types and Operators
C++ Data types
1. What are the fundamental data types in C++? 2
int, char, float, double, void
and void.
a. int – Used to represent integer numbers. Integers are whole numbers without fractional part. GCC
compiler allocates 4 bytes of memory for int data type.
Example : 100, -50, +10, 0
b. char – Used to represent characters. GCC compiler allocates 1 byte of memory for char data type.
Example : ‘A’, ‘+’, ‘5’
c. float – Used to represent floating point numbers. Floating point numbers are numbers with
fractional part. GCC allows 4 bytes of memory for float data type. It has a precision of 7 digits.
Example : 3.14
d. double – Used to represent floating point numbers with more precision. GCC allows 8 bytes of
memory for double data type. It has a precision of 15 digits.
e. void – Represents empty set of data. It does not require any memory.
Type Modifiers
1. What are the data type modifiers in C++? 2
signed, unsigned, long, short
Operators
1. A _________ operator, operates on a single operand. 1
unary
43. !, ++, %, == are operators used in C++. Categorize them into Arithmetic, Relational, logical and
increment operators. 2
Arithmetic - %
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®
Relational - ==
Logical - !
Increment - ++
5. Write the value returned by the following C++ expression if x=10 and y=20. 3
a) x>15 || y>15;
b) x>15 && y>15;
c) !(x>y)
a) 1 b) 0 c) 1
a) ? : b) >> c) ++ d) !
Expressions
1. Describe three types of C++ expressions with an example. 3
An expression is composed of operators and operands. On the basis of the operators used,
expressions are mainly classified into
a. arithmetic expressions
b. relational expressions
c. logical expressions.
a. Arithmetic expressions
An expression in which only arithmetic operators are used is called arithmetic expression. The
operands and results are of numeric data.
Example : 5+4 result is 9
b. Relational expressions
An expression in which only relational operators are used is called relational expression. The
operands are numeric data. The result will be True (1) or False (0).
Example : 5>4 result is 1
5<4 result is 0
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®
c. Logical expressions
An expression in which only logical operators are used is called logical expression. The
operands are relational expressions. The result will be True (1) or False (0).
Example: (5>4)&&(10>5) result is 1
!(5>4) result is 0
Type Conversion
1 . Briefly explain different types of type conversions in C++. 3
There are two types of conversions.
a. Implicit conversion (Type promotion)
b. Explicit conversion ( Type casting)
In expressions where different types of data are involved, C++ compiler converts the lower
sized operands to the data type of highest sized operand. It is known as type promotion.
Type casting is done by the programmer . This is done by specifying the data type within
parenthesis to the left of the operand.
a. 9
b. 9.5
Statements
1. Briefly discuss about the different types of statements in C++. 3
Statements are the smallest executable unit of a programming language. Different types of
statements used in C++ are
a. declaration statements
b. assignment statements
c. input statements
d. output statements
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®
a. Declaration statements
Declaration statements are used to declare variables.
Syntax
data_type variable;
Here data_type – any valid C++ data type.
Variable – variable name (identifier)
Example : int sum;
b. Assignment statements
The assignment statement is used to assign a value to a variable.
Syntax
variable = constant
or
variable1 = variable2
or
variable = expression
Example : x=10;
x=y;
x=a+b;
c. Input statements
Input statement is used to input a value from keyboard to a memory location.
Syntax
streamobject >> variable;
Example
cin >> num;
d. Output statements
Output statement is used to output a value from RAM to output device.
Syntax
streamobject << data;
Example
cout << num;
cout << "hello friends";
cout << num+12;
a. Preprocessor directive
A C++ program starts with Preprocessor directives. These are compiler directive
statements. It give instruction to the compiler to process the information provided before actual
compilation starts. These lines starts with the symbol #.
Example : #include, #define (#include is used to link header files in C++ library.)
Header files contain information about functions, objects etc.
Example: iostream – contains the information about the objects cin and cout.
b. namespace statement
Different identifiers are associated to a particular namespace. The keyword using tells
the compiler about a namespace where it should search for elements in a program.
6. The following C++ code segment is a part of a program to find the average of 3 numbers.
int a,b,c;
float avg;
cin>>a>>b>>c;
avg=(a+b+c)/3;
cout<<avg;
What will be the output if the inputs are 1,4 and 5? How can you correct it? 2
The output is 3.
change 3 into 3.0
The output is 4
0
Chapter 7
Control Statements
Decision Making Statements
1. Write the syntax of ‘if’ statement. 2
if(test expression)
{
statement block;
}
switch(a)
{
case 1 :cout ≪ “One”; break;
case 0 :cout ≪ “Zero”; break;
default :cout ≪ “Not a binary digit”;
}
------------------------------------------------------------------------
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®
Conditional Operator
1. Explain about conditional operator. 2
Conditional operator is a ternary operator. It requires three operands to operate. Its symbol is
‘?:’. It can be used as an alternative to if..else statement.
if(a>b)
cout<<a;
else
cout<<b;
if(a>b)
k=a-b;
else
k=b-a;
-----------------------------------------------------------------------------
Iteration Statements
1. Explain looping statements in C++. 3
Looping statements allow a set of instructions to be executed repeatedly when a condition is
True. C++ provides three loop statements: while loop, for loop and do...while loop.
All the loops have four components. They are Initialisation of loop control variable, Test
Expression, Body of the loop and Update statement.
Loops can be entry-controlled (while, for) or exit-controlled (do..while).
2. Write the names of any two entry controlled loops available in C++. 2
while, for
3. Name the type of loop which can be used to ensure that the body of the loop will surely be 1
executed at lest once.
do..while
4. What are the three looping or iteration statements in C++? Briefly explain about any one loop 3
with an example.
The three looping statements are while loop, for loop and do...while loop.
while statement
The while loop is an entry-controlled loop. The condition is checked first and if it is found
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®
Example
#include <iostream>
using namespace std;
int main()
{
int n=1;
do
{
cout << n << " ";
n++;
}while(n<=10);
}
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®
b) 0
9. Rewrite the following program using while and do ........ while loops. 3
#include<iostream>
using namespace std;
int main()
{
int i;
for (i=1;i<=10; i++)
{
cout<<i;
}
return 0;
}
using while
int main()
{
int i;
i=1;
while(i<=10)
{
cout<<i;
i++;
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®
}
return 0;
}
using do..while
int main()
{
int i;
i=1;
do
{
cout<<i;
i++;
} while(i<=10);
return 0;
}
10. What will be the output of the following program. Justify your answer. 2
#include<iostream>
using namespace std;
int main()
{
int a, b num;
for(a=1; a<=10; ++a)
{
for(b=1; b<=5; ++b)
num=a*b;
cout<<num<<endl;
}
return 0;
}
5
10
15
20
25
30
35
40
45
50
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®
In the inner loop, there is no brackets. So compiler assumes that there are two
statements – a for loop and a cout statement. So the product of ‘a’ value and 5 (the final value of
variable b is displayed.
11. Draw the flow chart for the execution of do... while loop in C++. 3
12. Write C++ code fragments to print the numbers from 1 to 10 using an exit or entry 3
controlled loop.
#include <iostream>
using namespace std;
int main()
{
int n = 1;
while(n <= 10)
{
cout << n << " ";
++n;
}
}
b) continue
initialisation expression
test expression
body of the loop
update expression
Jump Statements
1. Which statement in C++ can transfer control of a program to a labelled statement? 1
goto
2. What is the use of jump statement in a program? Explain the different types of jump statements 5
available in C++.
The statements that transfer the program control from one place to another is called Jump
statements. In C++ there are four jump statements. They are return, goto, break and continue.
return
The return statement is used to transfer control back to the calling program.
goto
The goto statement transfer the program control to anywhere in the program.
Syntax
goto label;
............;
............;
label: ..........;
............;
where label is an identifier.
Example:
int i=1;
start: cout<<i;
++i;
if (i<=50)
goto start;
If the test expression (i<=50) evaluates to true, the program control gors back to label start.
break
break statement takes the program control outside the loop or switch statement.
Example:
for(int i=1; i<=5; i++)
{
if i==3)
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®
break;
cout<<i<<”\t”;
}
Output: 1 2
continue
continue statement skips a part of the code and forces the next iteration.
Example:
for(int i=1; i<=5; i++)
{
if i==3)
continue;
cout<<i<<”\t”;
}
Output: 1 2 4 5
12346789
break continue
Used with switch and loops Used only with loops
takes the program control outside the loop or skips a part of the code and forces the next
switch statement. iteration.
Program control goes out of the loop even though Program control goes out of the loop only when
the test expression is True. the test expression becomes False.
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®
Programs
1. Write a program to check whether the given number is prime or not. 5
#include<iostream>
using namespace std;
int main()
{
int num,i;
cout<<"Enter a number ";
cin>>num;
for(i=2;i<num/2;i++)
{
if(num%i==0)
{
cout<<num<<" is not a Prime Number";
exit(0);
}
}
cout<<num<<" is a Prime Number";
return 0;
}
3. Write a program to print the leap years between 2000 and 3000. 5
#include<iostream>
using namespace std;
int main()
{
int year;
for(year=2000;year<=3000;year++)
{
if(year%400==0||year%4==0)
cout<<year<<"\t";
}
return 0;
}
4. Write a C++ program that accepts a list of integers as input and print sum of even integers. 5
#include<iostream>
using namespace std;
int main()
{
int N,num,i,sum=0;
cout<<"How many numbers? ";
cin>>N;
cout<<"Enter numbers ";
for(i=0;i<N;i++)
{
cin>>num;
if(num%2==0)
sum=sum+num;
}
cout<<"Sum = "<<sum;
return 0;
}
--------------------------------------------------------------------------------------------------------------------
Chapter 8
Arrays
Array and its need
1. What is an Array? Explain its need. 2
An array is a collection of elements of the same type placed in contiguous memory locations.
In situations where large data of same type is to be handled, large number of variables are to be
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®
2. Write C++ statement to declare an array which can store 5 integer values and explain about the
memory allocation of the array. 3
int num[5];
For this integer array, the total bytes of memory allocated
= sizeof (array_type) × size_of_array
=4x5
= 20 bytes.
int num[10];
total bytes = 4 x 25
= 200 bytes.
5. Write the initialization statement for an array with values 89, 75, 92, 65. 2
int x[4]={89,75,92,65};
85
8. What is meant by Index in an array? Explain its role in accessing array elements. 3
Any element in an array can be accessed by giving the array’s name and the element’s position.
This position is called the index or subscript value. In C++, the array index starts with zero. If an
array is declared as int num[10]; then the possible index values are from 0 to 9. The first element can
be referenced as num[0] and the last element as num[9].
a) 7
(i) 7
(ii) 4 x 5 = 20 bytes
Array Operations
1. Accessing the elements of an array at least once is called ______. 1
Traversal
3. Write C++ statements to double each element of the array int A[100]. 2
Sorting
4. Write an algorithm for selection sort. 3
Step 1 : Start
Step 2 : Accept N as the number of elements of the array
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®
5. If 24,54,89, 56,76, 42,5 are the elements of an array, illustrate the working of selection sort
algorithm for sorting these elements in descending order. 3
initial list
24 54 89 56 76 42 5
After Pass 1
5 54 89 56 76 42 24
After Pass 2
5 24 89 56 76 42 54
After Pass 3
5 24 42 56 76 89 54
After Pass 4
5 24 42 54 76 89 56
After Pass 5
5 24 42 54 56 89 76
After Pass 6
5 24 42 54 56 76 89
Pass 1
3 7 1 2 6
3 1 7 2 6
3 1 2 7 6
3 1 2 6 7
Pass 2
1 3 2 6 7
1 2 3 6 7
1 2 3 6 7
Pass 3
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®
1 2 3 6 7
1 2 3 6 7
Pass 4
1 2 3 6 7
Searching
6. Consider an array A with the following elements sorted in ascending order.
5, 9, 10, 13, 16, 17, 19, 20, 25, 37
Explain the working of binary search algorithm to search 25. How many comparisons are required
for this searching? 3
0 1 2 3 4 5 6 7 8 9
5 9 10 13 16 17 19 20 25 37
FIRST = 0, LAST = 9
MIDDLE = (FIRST + LAST) / 2 = (0+9) / 2 = 4.5 = 4
LIST[4] = 16 which is not equal to 25.
Step 6. Starting from the first position, repeat Step 7 until the last element
Step 7. Check whether the value in ITEM is found in the current position. If found then store
the position in LOC and Go to Step 8, else move to the next position.
Step 8. If the value of LOC is less than 0 then display "Not Found", else display the value of
LOC + 1 as the position of the search value.
Step 9. Stop
8. Compare Linear search with Binary search. 2
2. Write C++ statements to find the sum of the diagonal elements of array M[5][5]. 2
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®
sum=0;
for(i=0; i<5; i++)
{
sum = sum + M[i][i];
}
cout<<"\nSum of major diagonal elements is: " <<s;
--------------------------------------------------------------------------------------------------------------------
Chapter 9
String Handling and I/O functions
3. How many bytes are required to store the string “WELCOME ALL”? 1
12
In the first statement 10 memory locations will be allocated and the string will be stored with
null character as the delimiter. The last six bytes will be left unused.
But for the second statement, size of the array is not specified and hence only 4 bytes will be
allocated (3 bytes for the string and 1 for '\0' ).
2. Name the header file required if the elements of the array are to be printed using puts( ) function. 1
<cstdio>
3. What is the advantage of using gets() function in C++ program to input string data? Explain with
an example. 2
If “cin” is used to input a string that contains a space, only the word before space will be
inserted into the array. This is because a white space is treated as a separator of data.
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®
The gets() function is used to accept a string including white spaces from the standard input
device (keyboard).
5. What will be the output if we input the string "Vande Mataram”. Justify your answer. 2
2. Write and explain about any two functions defined in cstdio header file. 3
getchar() - This function returns the character that is input through the keyboard.
Eg: char ch = getchar();
putchar() - This function displays the character given as the argument on the monitor.
Eg: putchar(ch);
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®
hell
Miscellaneous
1. Write the use of the following string function in c++. 1
a. gets() b. getline() c. write()
Chapter 10
Functions
Concept of Modular Programming
1. Describe the merits of modular programming. 3
Reduces the size of the program: The modular approach helps to isolate the repeating task
and write instructions for this with a name. This can be invoked by using that name. Thus program
size is reduced.
Less chances of error: When the size of the program is reduced, naturally syntax errors will be
less in number. The chances of logical error will also be minimized.
Reduces programming complexity: If we divide the problem into smaller conceptual units
properly, the development of logic for the solution will be simpler.
Improves reusability: A function written once may be used later in many other programs.
Predefined functions
1. Name the built in function to check whether a character is alphanumeric or not. 1
isalnum()
8. List any three string functions in C++ and specify the value returned by them. 3
a. strlen() - This function is used to find the length of a string. It returns the number of
characters in a string.
b. strcmp() - This function is used to compare two strings.
The function returns any of the following values in three different situations.
Returns 0 if string1 and string2 are same.
Returns a –ve value if string1 is alphabetically lower than string2 .
Returns a +ve value if string1 is alphabetically higher than string2 .
c. strcmpi() - This function is used to compare two strings ignoring cases.
The function returns any of the following values in three different situations.
Returns 0 if string1 and string2 are same.
Returns a –ve value if string1 is alphabetically lower than string2.
Returns a +ve value if string1 is alphabetically higher than string2.
int main()
{
char str[] = “Green Computing”;
int n;
n=strlen(str);
cout<<n;
return 0;
}
Corrected Program.
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
char str[] = “Green Computing”;
int n;
n=strlen(str);
cout<<n;
return 0;
}
Output – 15
Corrected Program.
#include<iostream>
#include<cmath>
using namespace std;
int main ()
{
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®
int n=25;
float b=sqrt(n);
cout<<b;
return 0;
}
Output - 5
--------------------------------------------------------------------------------
where data_type – data type of the value returned by the function. any valid data type of C++.
function_name - user-defined word (identifier).
argument_list - which is optional, is a list of parameters
body - C++ statements
This is a function declaration statement. The function name is ‘sum’. It accepts two
integer values as arguments. It returns an integer value.
5. Explain the difference between call by value method and call by reference method with the help
of examples. 3
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®
Output - n = 21
x = 20
Output - n = 21
x = 21
------------------------------------------------------------------
Recursive functions
1. The process of calling a function by itself is known as ____________ 1
recursion
2. Read the function definition given below. Predict the output, if the function is called as convert(7) 2
void convert(int n)
{
if(n>1)
convert(n/2);
cout<<n%2;
}
Output - 111
3. Write a recursive C++ function that returns sum of the first n natural numbers. 2
int sumnatural(int x)
{
if(x==1)
return 1;
else if(x>1)
return(x+sumnatural(x-1));
}
-------------------------------------------------------------------------------------------------------------------------
Chapter 11
Computer Networks
Need for Network
1. Explain the advantages of forming networked computers than keeping stand-alone computers. 3
a. Resource sharing - The sharing of hardware and software resources in a computer network
is called resource sharing.
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®
b. Price-performance ratio - The cost of purchasing licensed software for each computer can
be reduced by purchasing network versions.
c. Communication - Computer network helps user to communicate with any other user of the
network through services like e-mail, chatting, video conferencing etc.
d. Reliability - It is possible to backup data/information in multiple computers using the
network. These can be retrieved from other computers in case of disasters.
e. Scalability - Computing capacity can be increased or decreased easily by adding or
removing computers to the network
Communication medium
1. Which one of the following transmission media carry information in the form of light signals? 1
a) coaxial cable b) shielded twisted pair cable c) optical fibre cable d) Wi-fi
c) optical fibre cable
a. Modem
A modem is an electronic device used for communication between computers
through telephone lines. It converts digital signals received from a computer to analog signals
(modulation) for telephone lines. It also converts the analog signals received from telephone
lines to digital signals (demodulation) for the computer.
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®
b. Multiplexer
Multiplexing is sending multiple signals on a physical medium at the same time
and then recovering the separate signals at the receiving end.
Multiplexing divides the physical medium into different frequency channels. Multiplexer
combines (multiplexes) the inputs from different sources and sends them through different channels
of a medium. At the destination, a demultiplexer separates (demultiplexes) the signals and sends
them to destinations.
Network topologies
1. In ........ network topology, each node is directly connected to a hub/ switch. 1
Star Topology
Bus Topology
In bus topology all the nodes are connected to a main cable called bus. If a node has to
send data to another node, it sends data to the bus. The signal travels through the entire length of the
bus. All nodes check the bus, and only the node for which data is addressed accepts it.
Star Topology
Join Now: https://join.hsslive.in Downloaded from https://www.hsslive.in ®
In star topology each node is directly connected to a hub/switch. If any node has to send some
information to any other node, it sends the signal to the hub/switch. This signal is then
broadcasted (in case of a hub) to all the nodes but is accepted only by the intended node. In the case
of a switch, the signal is sent only to the intended node.
Ring Topology
A ring topology is in the form of a circle. Data travels only in one direction. While they
are passed from one node to the next, each node regenerates the signal. The node for which the
signal is intended reads the signal. After travelling all the nodes, the signal reaches back to the
sending node from where it is removed.
Mesh topology
In mesh topology, every node is connected to other nodes. So there will be more than
one path between two nodes. If one path fails, the data will take another path and reach the
destination.
Types of networks
1. Internet is an example of __________. 1
WAN
On the basis of the area covered, computer networks are classified as:
a) PAN - Personal Area Network
b) LAN - Local Area Network
c) MAN - Metropolitan Area Network
d) WAN -Wide Area Network
a. PAN
PAN is a network that can cover an area of a few meters.
Example : PC to MP3 player.
b. LAN
LAN is a network that can cover an area of a few meters to a few Kilometers. A LAN is
owned, controlled and managed by a single person or an organisation.
Example : Network in a room, building or a campus.
c. MAN
MAN is a network that can cover an area of a few Kilometers to a few hundred
Kilometers (within a city). MAN is typically owned and operated by a single entity such as a
government body or a large corporation.
Example : Cable TV connection in a city.
d. WAN
WAN is a network crossing the limits of a city, country or continent. It can cover an area
of over hundreds of Kilometers in radius.
Example : Internet, A network of ATMs, banks, government offices spread over a country, continent.
Network protocols
1. Define protocol. 1
A network protocol is a set of rules to be followed when devices in the network exchange
data with each other.
Chapter 12
Internet and Mobile Computing
Types of connectivity
1. Compare the DiaI up connection and Wired broadband connection. 3
can be accessed in Wi-Fi enabled devices like laptops, tablets, mobile phones, etc. through
hotspots. A drawback of Wi-Fi is that it is less secure than wired connections.
Services on Internet
1. Name any two services over internet. 2
World wide web, Search engines, E-mail, social media
2. Explain about Search Engines. 3
Search engine programs search documents on World Wide Web for specified keywords and
return a list of the web pages matching the keywords.
Example : Google, Bing, Yahoo Search, Ask
Search engine web sites use programs called web crawlers or spiders or robots to search the web.
Web crawlers search the web pages stored in the different web servers and find possible keywords.
The search engine website stores these keywords along with their URLs to form an index in the web
servers.
Bring people together, Plan and organise events, Business promotion, Social skills.
Cyber Security
1. Find the best matches from the given definitions for the terms in the given list. 2
(Worm, Hacking, Phishing, Spam)
a) Unsolicited emails sent indiscriminately.
b) A technical effort to manipulate the normal behavior of networked computer system.
c) A stand-alone malware program usually makes the data traffic slow.
d) Attempt to acquire information like usernames and passwords by posing as the original
web site.
e) Appear to be a useful software but will do manage like deleting necessary files.
Worm - c) A stand-alone malware program usually makes the data traffic slow.
Hacking - b) A technical effort to manipulate the normal behavior of networked computer
system.
Phishing - d) Attempt to acquire information like usernames and passwords by posing as the
original web site.
Spam - a) Unsolicited emails sent indiscriminately.
incoming data and determines whether they should be allowed or not based on a rule set.
Mobile Communication
1. SIM card is a smart card used inside a mobile phone. What is the full form of SIM? 1
Subscriber Identity Module
Miscallaneous
1. Write a short note about : 3
(a) Fibre to Home (FTTH) (b) Phishing (c) Android Operating system
(a) Fibre to Home (FTTH) – Its a wired broadband connectivity. It Uses optical fibers for data
transmission. They provide very high speed connectivity.
(b) Phishing - Phishing is an attempt to acquire information such as usernames, passwords and
credit card details by posing as the original website.
(c) Android Operating system - Android is a Linux-based operating system designed mainly for
touch screen mobile devices such as smart phones and tablet computers.