Xi - Computer Science Reduced Syllabus Study Materials 2021-2021
Xi - Computer Science Reduced Syllabus Study Materials 2021-2021
XI - COMPUTER SCIENCE
Reduced syllabus
STUDY MATERIAL
2021-2022
NAME
STD & GROUP
PREPARED BY
TABLE OF CONTENTS
COMPUTER SCIENCE – I YEAR
2 NUMBERS SYSTEMS
3 COMPUTER ORGANISATION
10 FLOW OF CONTROL
11 FUNCTIONS
15 POLYMORPHISM
16 INHERITANCE
18 TAMIL COMPUTING
1. INTRODUCTION TO COMPUTERS
Choose the correct answer: (1 mark)
1. First generation computers used
(a)Vacuum tubes (b) Transistors (c) Integrated circuits (d) Microprocessors
10. Which generation of computer used IC’s?
(a) First (b) Second (c) Third (d) Fourth
Very Short Answers (2 mark)
1. What is a computer?
• A computer is an electronic device that processes the input according to the set of instructions provided
to it and gives the desired output at a very fast rate.
2. Distinguish between data and information.
Data Information
Data is defined as an unprocessed collection Information is a collection of facts from which
of raw facts, suitable for communication, conclusions may be drawn.
interpretation or processing.
Example: 134, 16 ‘Kavitha’, ‘C’are data. Example: Kavitha is 16 years old.
Short Answers (2 mark)
1. What are the characteristics of a computer?
Computers have revolutionized our lives with their speed, accuracy, storage, reliability, versatility and
diligence performing a job, it is truly remarkable.
2. Write the applications of computer.
Computers are seen everywhere around us, in all spheres of life, in the field of education, research, travel
and tourism, weather forecasting, social networking, e-commerce, Robotics , Nanotechnology,
Bioengineering etc.
Explain in detail (5 mark)
2. Discuss the various generations of computers.
SN Generation Period Main Component Merits/Demerits
used
• Big in size
1 First • Consumed more power
Generation 1940-1956 Vacuum tubes • Malfunction due to overheat
• Machine Language was used
• Smaller compared to First Generation
• Generated Less Heat
• Consumed less power compared to first
generation
Second • Punched cards were used
2 Generation 1956-1964 Transistors • First operating system was developed
Batch Processing and Multiprogramming
Operating System
• Machine language as well as Assembly
language was used.
(46)10 = (101110)2
4. We cannot find 1’s complement for (28)10. State reason.
Reason: We cannot find 1’s complement for (28)10. Because it is a positive number. 1’s complement
apply only with negative number.
Short Answers (3 mark)
1. What is radix of a number system? Give example
• Each number system is uniquely identified by its base value or radix.
• Radix or base is the count of number of digits in each number system.
• Radix or base is the general idea behind positional numbering system.
• Radix or base is the general idea behind positional numbering system.
Example:
Binary Number System - Radix 2 (1010)2
Octal Number System - Radix 8 (457)8
Decimal Number System - Radix 10 (312)10
Hexadecimal Number System - Radix 16 (25F)16
2. Write note on binary number system.
• There are only two digits in the Binary system, namely, 0 and 1.
• The numbers in the binary system are represented to the base 2 and the positional multipliers are the
powers of 2.
• The left most bit in the binary number is called as the Most Significant Bit (MSB)and it has the largest
positional weight.
• The right most bit is the Least Significant Bit (LSB) and has the smallest positional weight.
3. Convert (150)10 into Binary, then convert that Binary number to Octal
2 150 LSB
2 75 -0
2 37 -1
2 18 -1
2 9 -0
2 4 -1
2 2 -0
MSB 1 -0
(150)10 = (10010110)2
5. Add a) -2210+1510
2 22 LSB
2 11 -0
2 5 -1
2 2 -1
MSB 1 -0 The Binary equivalent of 2210 = (10110)2
2 15 LSB
2 7 -1
2 3 -1
MSB 1 -1 The Binary equivalent of 1510 = (111)2
−710 = (11111001)2
b) 2010+2510
2 20
2 10 - 0 LSB
2 5 -0
2 2 -1
MSB 1 -0 The Binary equivalent of 2010 = (10100)2
2 25 LSB
2 12 -1
2 6 -0
2 3 -0
MSB 1 -1 The Binary equivalent of 2510 = (11001)
4510 = (00101101)2
9810 = (1100010)2
ii) Fraction Part
0.46 × 2 = 0.92 = 0
0.92 × 2 = 1.84 = 1
0.84 × 2 = 1.68 = 1
0.68 × 2 = 1.36 = 1
0.36 × 2 = 0.72 = 0
0.72 × 2 = 1.44 = 1
0.44 × 2 = 0.88 = 0
4610 = (0111010)2
(98.46)10 = (1100010. 0111010….)2
2. Find 1’s Complement and 2’s Complement for the following Decimal number
a) -98
2 98 LSB
2 49 -0
2 24 -1
2 12 -0
2 6 -0
2 3 -0
MSB 1 -1 The Binary equivalent of 9810 = (1100010)2
b) -135
2 135 LSB
2 67 -1
2 33 -1
2 16 -1
2 8 -0
2 4 -0
2 2 -0
MSB 1 -0 The Binary equivalent of 13510 = (1000111)2
Folder and sub folder cannot be created in a file Folder and sub folder can be created in a folder
4. Differentiate Save and Save As option.
Save Save As
“Save” command is used to save a document “Save As” command can save a file by two or
by only one name more than two names.
Shortcut Keys : Ctrl + S Shortcut Keys : Ctrl+Shift+S
5. How will you Rename a File?
• Rename files or folders can be done in number of ways such as using the File menu, left mouse button
or right mouse button.
1. Select the File
2. Click File→ Rename.
3. Type in the new name.
4. To finalise the renaming operation
Short Answers (3 mark)
1. What are the functions of Windows Operating system?
• Access applications on the computer.
• Load any new program on the computer.
• Manage hardware.
• File management activities.
• Change computer settings.
3. Write a note on the elements of a window.
Title Bar
• The title bar will display the name of the application and the name of the document opened.
Menu Bar
• Menus in the menu bar can be accessed by pressing Alt key and the letter that appears underlined in
the menu title.
The Workspace
• The workspace area is used to enter or type the text of your document.
Scroll bars
• The scroll bars are used to scroll the workspace horizontally or vertically.
Corners and borders
• The corners and borders of the window helps to drag and resize the windows.
4. Write the two ways to create a new folder.
Method I:
Step 1: Open Computer Icon.
Step 2: Open any drive where you want to create a new folder.
Step 3: Click on File → New → Folder.
Step 4: A new folder is created with the default name “New folder”
Step 5: Type in the folder name and press Enter key.
Method II:
In order to create a folder in the desktop:
Step 1: In the Desktop, right click → New → Folder
Step 2: A Folder appears with the default name “New folder” and it will be highlighted.
Step 3: Type the name you want and press Enter Key.
Step 4: The name of the folder will change.
5. Differentiate copy and move.
Copy Move
Copy option is used to copy a file or folder, Cut option is used to move a selected file or
and paste in a specified location. folder from one place to another.
Edit → Copy or Ctrl + C or Right click→ Edit → Cut or Ctrl + X or Right click → Cut
Copy
6. farmer, grass := R, R
7. – – farmer , goat , grass , wolf = R, R, R, L
8. farmer, goat := L, L
9. – – farmer, goat, grass, wolf = L, L, R, L
10. farmer, wolf := R, R
11. – – farmer , goat , grass , wolf = R, L, R, R
12. farmer : = L
13. – – farmer , goat , grass , wolf = L, L, R, R
14. farmer , goat : = R, R
15. – – farmer , goat , grass , wolf = R, R, R, R
4. Specify a function to find the minimum of two numbers.
ANSWER:
Minimum (A,B)
– – Inputs: A and B are integers (or) Real numbers
– – Outputs: A is minimum (A<B) (or) B is minimum (B<A)
5. If √2 = 1.414, and the square_root() function returns -1.414, does it violate the following
specification?
-- square_root (x)
-- inputs: x is a real number , x ≥ 0
-- outputs: y is a real number such that y2=x
ANSWER:
No, because (- 1.414)2 = 2, which satisfies input – output relation (y2= x)
Short Answers (3 mark)
1. When do you say that a problem is algorithmic in nature?
• A problem is algorithmic in nature when its solution involves the construction of an algorithm.
• Some types of problems can be immediately recognized as algorithmic using input and output data.
2. What is the format of the specification of an algorithm?
Specification format: We can write the specification in a standard three part format:
1. The name of the algorithm and the inputs.
algorithm_name (inputs)
2. Input: the property of the inputs.
– – inputs : P
3. Output: the desired input-output relation.
– – outputs: Q
3. What is abstraction?
• Ignoring or hiding unnecessary details and modeling an entity only by its essential properties is known
as abstraction.
Example:
• When we represent the state of a process, we select only the variables essential to the problem and
ignore inessential details.
4. How is state represented in algorithms?
• The state of a process can be represented by a set of variables in an algorithm.
• The state at any point of execution is simply the values of the variables at that point.
• As the values of the variables are changed, the state changes.
5. What is the form and meaning of assignment statement?
• Assignment statement is used to store a value in a variable.
• It is written with the variable on the left side of the assignment operator and a value on the right side.
• Assignment statement : variable := value
Example:
m := 2
It stores value 2 in variable m.
You intend to use the formula and you are prepared to handle only real number roots. Write a
suitable Specification.
1. Exchange ( )
2. – – inputs: a, b, c := Apple, Grape, Empty
3. – – outputs: a, b, c: = Grape, Apple, Empty
7. COMPOSITION AND DECOMPOSITION
Choose the correct answer: (1 mark)
1. Suppose u, v = 10 ,5 before the assignment. What are the values of u and v after the sequence of
assignments?
1 u := v
2 v := u
(a) u, v = 5 ,5 (b) u, v = 5 ,10 (c) u, v = 10 ,5 (d) u, v = 10 ,10
2. Which of the following properties is true after the assignment (at line 3?
1 --i, j = 0, 0
2 i, j := i+1, j-1
3 -- ?
(a) i+j >0 (b) i+j < 0 (c) i+j =0 (d) i = j
3. If C1 is false and C2 is true, the compound statement
1 if C1
2 S1
3 else
4 if C2
5 S2
6 else
7 S3
executes
(a) S1 (b) S2 (c) S3 (d) none
4. If C is false just before the loop, the control flows through
1 S1
2 while C
3 S2
4 S3
(a) S1 ; S3 (b) S1 ; S2 ; S3 (c)S1 ; S2 ; S2 ; S3 (d) S1 ; S2 ; S2 ; S2 ; S3
5. If C is true, S1 is executed in both the flowcharts, but S2 is executed in
(a) (1) only (b) (2) only (c) both (1) and (2) (d) neither (1) nor (2)
6. How many times the loop is iterated?
i := 0
while i ≠ 5
i := i + 1
(a) 4 (b) 5 (c) 6 (d) 0
SECTION-B (2 mark)
Very Short Answers
1. Distinguish between a condition and a statement.
CONDITION STATEMENT
3. Both conditional statement and iterative statement have a condition and a statement. How do
they differ?
CONDITION STATEMENT ITERATIVE STATEMENT
• Iterative statement repeatedly evaluates a
• Conditional statement is executed only if the
condition and executes a statement as long
condition is true. Otherwise, nothing is done.
as the condition is true.
• If, If Else are the examples of Conditional • While, Do While are the examples of
Statements Iterative Statements
PSEUDO CODE:
1. Start
2. Input A,B
3. If A>B then Prints “S1” and “S2”
4. End
PSEUDO CODE:
1. Start
2. Input A,B
3. If A>B then Prints “S1”
4. Else print “S2”
5. End
22 Visit :http://www.youtube.com/c/CSKNOWLEDGEOPENER CS KNOWLEDGE OPENER
J. ILAKKIA M.Sc., B.Ed., M.Phil. Computer Instructor Grade-I, GHSS – V.Pagandai, Villupuram.
2. Circulate the contents: Write the specification and construct an algorithm to circulate the
contents of the variables A, B and C as shown below: The arrows indicate that B gets the value of A,
C gets the value of B and A gets the value of C.
SPECIFICATIONS:
1. circulate
2. – – inputs: a, b, c: = A, B, C
3. – – outputs: a, b, c: = C, A, B
ALGORITHM:
1. circulate (a, b, c)
2. – – a, b, c: = A, B, C
3. temp : = c
4. c : = b
5. b : = a
6. a : = temp
7. – – a, b, c: = C, A, B
3. Decanting problem. You are given three bottles of capacities 5 ,8, and 3 litres. The 8L bottle is
filled with oil, while the other two are empty. Divide the oil in 8L bottle into two equal quantities.
Represent the state of the process by appropriate variables. What are the initial and final states
of the process? Model the decanting of oil from one bottle to another by assignment. Write a
sequence of assignments to achieve the final state.
(a) MODEL:
Let a, b, c be the variables whose maximum values are 8L, 5L and 3L respectively.
Initial State: a, b, c := 8, 0, 0
Bottel 1 = 8 L Bottel 2 = 5 L Bottel 3 = 3 L
a b c
Final State: a, b, c := 4, 4, 0
Bottel 1 = 8 L Bottel 2 = 5 L Bottel 3 = 3 L
a b c
(b) SPECIFICATION:
decant
– – inputs: a, b, c : = 8, 0, 0
– – outputs: a, b, c : = 4, 4, 0
(c) ALGORITHM:
Let us assume that a: = b denotes oil in b is poured into a bottle until either “a” is full or “b” becomes
empty.
decant (a, b, c)
– – a, b, c : = 8, 0, 0
b:=a
– – a, b, c : = 3, 5, 0
c:=b
– – a, b, c : = 3, 2, 3
a:=c
– – a, b, c : = 6, 2, 0
c:=b
– – a, b, c : = 6, 0, 2
b:=a
– – a, b, c : = 1, 5, 2
c:=b
– – a, b, c : = 1, 4, 3
a:=c
– – a, b, c: = 4, 4, 0
ALGORITHM TRACE:
f =1
f=f*i i = i +1
i =1
1st iteration f=1x1=1 i=1+1=2
LOOP TERMINATES
• Therefore it is not possible to reach a situation where all the tumblers are right side up.
Explain in Detail (5 mark)
1. Assume an 8 × 8 chessboard with the usual coloring. "Recoloring" operation changes the color of
all squares of a row or a column. You can recolor re-peatedly. The goal is to attain just one black
square. Show that you cannot achieve the goal. (Hint: If a row or column has b black squares, it
changes by (|8 - b) - b|).
ANSWER:
In a chess board no. of squares in any row or column = 8
Total No. of squares = 8 x 8 = 64
No. of black squares = 32
No. of white squares = 32
Let No. of blacks in a selected recoloring row or column = b
No. of black squares after recoloring operation = 8 – b
Initial state b = 32
Desired final state b = 1
Let us tabulate all the possible outcomes after recoloring a row or column.
No. of Black Squares No. of Black Squares
Difference Difference
in a row or column in a row or column
= |b – (8−b)| (even or odd)
before recoloring (b) before recoloring (−b)
1 7 6 even
2 6 4 even
3 5 2 even
4 4 0 Zero (even)
5 3 2 even
6 2 4 even
7 1 6 even
Difference is the no. of black squares left out in a row or column after recoloring operation. Difference is
even. Difference is invariant.
But our goal is one ( 1 is odd) black square, so, it is not possible to attain the goal.
9. INTRODUCTION TO C++
Choose the correct answer (1 mark)
1. Who developed C++?
(a) Charles Babbage (b) Bjarne Stroustrup (c) Bill Gates (d) Sundar Pichai
2. What was the original name given to C++?
(a) CPP (b) Advanced C (c) C with Classes (d) Class with C
3. Who coined C++?
(a) Rick Mascitti (b) Rick Bjarne (c) Bill Gates (d) Dennis Ritchie
4. The smallest individual unit in a program is:
(a) Program (b) Algorithm (c) Flowchart (d) Tokens
29 Visit :http://www.youtube.com/c/CSKNOWLEDGEOPENER CS KNOWLEDGE OPENER
J. ILAKKIA M.Sc., B.Ed., M.Phil. Computer Instructor Grade-I, GHSS – V.Pagandai, Villupuram.
(3)Logical Operators
• A logical operator is used to evaluate logical by combining two relational expressions into one.
• The logical operators act upon the operands that are themselves called as logical expressions.
• AND, OR both are binary operators and NOT is a unary operator.
Operator Operation Description
• It returns 1 (True), if both expression are true, otherwise it returns 0
&& AND (false).
• It returns 1 (True), if either one of the expression is true. It returns 0
|| OR (false), if both the expressions are false.
• NOT works on a single operand.
! NOT • It simply negates or inverts the value. i.e., if it is 1 (true) then returns
0 (false) and vice versa
(4)Assignment Operator:
• = (equal to) is the Assignment operator is used to assign a value on the right handside to a variable
which is on the left hand side .
• It is also a binary operator.
Operator Name of Operator Example
a = 10;
+= Addition Assignment c = a += 5;(ie, a = a + 5)
c = 15
a = 10;
-= Subtraction Assignment c = a -= 5;(ie. a = a – 5)
c=5
a = 10;
*= Multiplication Assignment c = a *= 5;(ie. a = a * 5)
c = 50
a = 10;
/= Division Assignment c = a /= 5;(ie. a = a / 5)
c=2
a = 10;
%= Modulus Assignment c = a %= 5; (ie. a = a % 5)
c=0
(5) Conditional Operator:
• ?: is a conditional Operator which is also known as Ternary Operator.
• This operator is used as an alternate to if … else control statement.
2. What are the types of Errors?
Type of Error Description
• Syntax is a set of grammatical rules to construct a program.
• Syntax errors occur when grammatical rules of C++ are violated.
• Example: if you type as follows, C++ will throw an error.
Syntax Error cout << “Welcome to Programming in C++”
33 Visit :http://www.youtube.com/c/CSKNOWLEDGEOPENER CS KNOWLEDGE OPENER
J. ILAKKIA M.Sc., B.Ed., M.Phil. Computer Instructor Grade-I, GHSS – V.Pagandai, Villupuram.
• A Program has not produced expected result even though the program is
grammatically correct.
Semantic Error • It may be happened by wrong use of variable / operator / order of execution etc.
• This means, program is grammatically correct, but it contains some logical error.
So, Semantic error is also called as “Logical Error”.
• A run time error occurs during the execution of a program.
Run-time error • It occurs because of some illegal operation that takes place.
• Example: If a program tries to open a file which does not exist, it results in a
run-time error
DATA TYPES, VARIABLES AND EXPRESSIONS
Choose the correct answer (1 Mark)
1. How many categories of data types are available in C++?
(a) 5 (b) 4 (c) 3 (d) 2
2. Which of the following data types is not a fundamental type?
(a) signed (b) int (c) float (d) char
3. What will be the result of following statement?
char ch= ‘B’;
cout << (int) ch;
(a) B (b) b (c) 65 (d) 66
4. Which of the character is used as suffix to indicate a floating point value?
(a) F (b) C (c) L (d) D
5. How many bytes of memory is allocated for the following variable declaration if you are using
Dev C++? short int x;
(a) 2 (b) 4 (c) 6 (d) 8
6. What is the output of the following snippet?
char ch = ‘A’;
ch = ch + 1;
(a) B (b) A1 (c) F (d) 1A
7. Which of the following is not a data type modifier?
(a) signed (b) int (c) long (d) short
8. Which of the following operator returns the size of the data type?
(a) sizeof( ) (b) int ( ) (c) long ( ) (d) double ( )
9. Which operator is used to access reference of a variable?
(a) $ (b) # (c) & (d) !
Very Short Answers (2 Mark)
1. Write a short note on const keyword with an example.
• const is the keyword used to declare a constant.
• const keyword modifies / restricts the accessibility of a variable.
• It is known as Access modifier.
34 Visit :http://www.youtube.com/c/CSKNOWLEDGEOPENER CS KNOWLEDGE OPENER
J. ILAKKIA M.Sc., B.Ed., M.Phil. Computer Instructor Grade-I, GHSS – V.Pagandai, Villupuram.
For example,
int num = 100;
3. Why is char often treated as integer data type?
• Character data type accepts and returns all valid ASCII characters.
• Character data type is often said to be an integer type, since all the characters are represented in
memory by their associated ASCII Codes.
• If a variable is declared as char, C++ allows storing either a character or an integer value.
4. What is a reference variable? What is its use?
• A reference provides an alias for a previously defined variable.
• Declaration of a reference consists of base type and an & (ampersand) symbol; reference variable
name is assigned the value of a previously declared variable.
Syntax:
<type> <& reference_variable> = <original_variable>;
5. Consider the following C++ statement. Are they equivalent?
char ch = 67; char ch = ‘C’;
Yes, they are equal
• Both the statements are equivalent as they declare ‘ch’ to be char and initialize it with the value of
67.
• Since this is the ASCII code for ‘C’, the character constant also can be used to initialize ‘ch’ to 67.
6. What is the difference between 56L and 56?
56L 56
• The suffix L forces the constant to be • This will be represented as int type
represented as long, which occupies 4 constant which occupies 2 bytes as per
bytes. Turbo C++.
7. Determine which of the following are valid constant? And specify their type.
(i) 0.5 (ii) ‘Name’ (iii) ‘\t’ (iv) 27,822
i) 0.5 – is a valid Floating constant.
ii) ‘Name’ – Invalid constant as single quote is not allowed.
iii) ‘\t’ – Escape sequence (or) non – graphical character (horizontal tab).
iv) 27,822 – Invalid constant. Comma is not allowed.
8. Suppose x and y are two double type variable that you want add as integer and assign to an
integer variable. Construct a C++ statement to do the above.
Answer:
double x=11.5; y=3.5;int a;
a = int (x) + int (y);
9. What will be the result of following if num=6 initially.
(a) cout << num; (b) cout << (num==5);
Answer:
(a) 6
(b) False
10. Which of the following two statements are valid? Why? Also write their result.
(i) int a; a = 3,014; (ii) int a; a=(3,014);
Answer:
i) It is invalid as comma is not allowed in an integer constant.
ii) It is valid. Comma in bracket is allowed.
Short Answers (3 Mark)
1. What are arithmetic operators in C++? Differentiate unary and binary arithmetic operators.
Give example for each of them.
• Arithmetic operators perform simple arithmetic operations like addition, subtraction,
multiplication, division etc.,
• The above mentioned arithmetic operators are binary operators which requires minimum of two
operands.
Unary Operators Binary Operators
• Require only one operand • Require two operands
• Ex: +, -, *, /, %, >, <, <=, AND, OR • Ex: ++ (Plus, Plus) Increment operator, – –
(Minus, Minus) Decrement operator, NOT, ~,
2. How relational operators and logical operators are related to one another?
• Relational operators are used to determine the relationship between its operands.
• When the relational operators are applied on two operands, the result will be a Boolean value 1 or
0 which represents True or False respectively which represents logical operator.
3. Evaluate the following C++ expressions where x, y, z are integers and m, n are floating point
Numbers. The value of x = 5, y = 4 and m=2.5;
(i) n = x + y / x; (ii) z = m * x + y; (iii) z *= x * m + x;
1. n = x + y / x;
= 5 + 4/5
= 5 + 0 (both x and y are int type. Therefore only integer part of quotient is considered)
=5
2. z = m * x + y;
= 2.5 * 5 + 4 (m is float type, so x value is promoted to float [implicit conversion])
= 12.5 + 4 ‘
= 16 (2 is int type. So ‘.2’, the fractional part is discarded)
3. z = (x++) * m + x;
= 5*2.5 + x
= 12.5 + 5
= 18 (z is int type, therefore the fractional part is removed, x is incremented after the addition)
• Switch statement
3. Correct the following code segment : if (x=1)
p= 100;
else
p = 10;
Corrected Coding:
if (x==1) Relational operator should be used instead of assignment operator
p= 100;
else
p = 10;
4. What will be the output of the following code:
int year;
cin >> year;
if (year % 100 == 0)
if ( year % 400 == 0)
cout << "Leap";
else
cout << "Not Leap year";
If the input given is (i) 2000 (ii) 2003 (iii) 2010?
Output:
i) Leap year
ii) Not Leap year
iii) Not Leap year
5. What is the output of the following code?
for (int i=2; i<=10 ; i+=2)
cout << i;
Output:
2 4 6 8 10
6. Write a for loop that displays the number from 21 to 30.
#include<iostream>
using namespace std;
int main()
{
int i;
for (i=21; i<=30 ; i++)
cout << i;
return 0;
}
7. Write a while loop that displays numbers 2, 4, 6, 8.......20.
Coding:
#include<iostream>
using namespace std;
38 Visit :http://www.youtube.com/c/CSKNOWLEDGEOPENER CS KNOWLEDGE OPENER
J. ILAKKIA M.Sc., B.Ed., M.Phil. Computer Instructor Grade-I, GHSS – V.Pagandai, Villupuram.
int main()
{
int i=2;
while(i<=20)
{
cout<<i<< "\t";
i+=2;
}
return 0;
}
8. Compare an if and a ? : operator.
if ?:
• The if statement evaluates a condition, if • In the conditional operator or Ternary operator
the condition is true then a true-block (?:) the expression 1 is a condition which is
statements will be executed, otherwise the evaluated, if the condition is true (Non-zero),
true-block is skipped then the control is transferred to expression 2,
otherwise, the control passes to expression 3.
Syntax: Syntax:
if (expression)
true-block; expression 1? expression 2 : expression 3
statement-x;
Answer:
int v=5;
do
{
39 Visit :http://www.youtube.com/c/CSKNOWLEDGEOPENER CS KNOWLEDGE OPENER
J. ILAKKIA M.Sc., B.Ed., M.Phil. Computer Instructor Grade-I, GHSS – V.Pagandai, Villupuram.
total+=v;
cout<<total;
v=v+1;
} while (v<=10);
3. Write a C++ program to print multiplication table of a given number.
Coding:
#include<iostream>
using namespace std;
int main()
{
int num;
cout<< “Enter Number to find multiplication table”;
cin>>num;
for(int a=1; a<=10; a++)
{
cout<<num<< “*”<<a<< “=”<<num*a<<endl;
}
return 0;
}
4. Write the syntax and purpose of switch statement.
Syntax:
switch(expression)
{
case constant 1:
statement(s);
break;
case constant 2:
statement(s);
break;
.
.
default:
statement(s);
}
Purpose:
• The switch statement is a multi-way branch statement which provides an easy way to dispatch
execution to different parts of code based on the value of the expression.
• It replaces multiple if-else sequence.
5. Write a short program to print following series:
(a) 1 4 7 10...... 40
#include<iostream>
using namespace std;
40 Visit :http://www.youtube.com/c/CSKNOWLEDGEOPENER CS KNOWLEDGE OPENER
J. ILAKKIA M.Sc., B.Ed., M.Phil. Computer Instructor Grade-I, GHSS – V.Pagandai, Villupuram.
int main()
{
int i;
for(int i=1; i<=40; i+=3)
{
cout<<i<<"\t";
}
return 0;
}
Explain in detail (5 Mark)
2. What is an entry control loop? Explain any one of the entry controlled loop with suitable
example.
Entry Controlled Loop:
• The for loop is an entry- controlled loop.
• It is the easiest looping statement which allows code to be executed repeatedly.
• It contains three different statements (initialization, condition or test-expression and update
expression(s)) separated by semicolons.
Syntax:
for (initialization(s); test-expression; update expression(s))
{
Statement 1;
Statement 2;
………….
}
Statement-x;
Working of for loop:
• The initialization part is used to initialize variables or declare variable which are executed only once,
then the control passes to test-expression.
• After evaluation of test-expression, if the result is false, the control transferred to statement-x.
• If the result is true, the body of the for loop is executed, next the control is transferred to update
expression.
• After evaluation of update expression part, the control is transferred to the test-expression part.
• Next the steps 3 to 5 is repeated. The workflow of for loop and flow chart are shown below.
Flowchart:
Example Program:
#include <iostream>
using namespace std;
int main ()
{
int i;
for(i = 0; i< 5; i ++ )
cout<< "value of i : " <<i<<endl;
return 0;
}
Output:
value of i : 0
value of i : 1
value of i : 2
value of i : 3
value of i : 4
3. Write a program to find the LCM and GCD of two numbers.
#include <iostream>
using namespace std;
int main ()
{
int n1, n2, a, b, gcd, lcm;
cout<< “Enter two numbers:”<<endl;
cin>>n1>>n2;
a=n1;
b=n2;
while(n1!=n2)
{
if(n1>n2)
n1=n1-n2;
else
n2=n2-n1;
}
gcd=n1;
cout<< “GCD=”<<gcd;
lcm=(a*b)/gcd;
cout<< “LCM=”<<lcm;
}
Output:
Enter two numbers
20
30
GCD=10 LCM=60
4. Write programs to find the sum of the following series:
#include<iostream>
#include<conio.h>
#include<math.h>
using namespace std;
int fact(int n)
{
int f=1;
for(int i=1;i<=n;i++)
f*=i;
return f;
}
int main()
{
int x,s=1;
float sum=0;
cout<<"Enter the value for x:";
cin>>x;
for(int i=1;i<=6;i++)
{
sum=sum+s*(pow(x,i)/fact(i));
s*=-1;
}
cout<<"Sum of series is "<<sum<<endl;
getch();
return 0;
}
#include<iostream>
#include<conio.h>
#include<math.h>
using namespace std;
int main()
{
int x,n;
float sum=0;
cout<<"Enter the value for x:";
cin>>x;
{
int a=x*x;
cout<<"\n\nThe Value inside display function (a * a):"<<a;
}
int main()
{
int a;
cout<<”\nExample : Function call by value:”;
cout<<"\n\nEnter the Value for A :";
cin>>a;
display(a);
cout<<"\n\nThe Value inside main function "<<a;
return(0);
}
Output :
Example : Function call by value
Enter the Value for A : 5
The Value inside display function (a * a) : 25
The Value inside main function 5
2. What is Recursion? Write a program to find the factorial of the given number using recursion.
• A function that calls itself is known as recursive function.
• And, this technique is known as recursion.
Example to find Factorial of a Number Using Recursion:
#include <iostream>
using namespace std;
int factorial(int); // Function prototype //
int main()
{
int no;
cout<<"\nEnter a number to find its factorial: ";
cin >> no;
cout << "\nFactorial of Number " << no <<" = " << factorial(no);
return 0;
}
int factorial(int m)
{
if (m > 1)
{
return m*factorial(m-1);
}
else
{
46 Visit :http://www.youtube.com/c/CSKNOWLEDGEOPENER CS KNOWLEDGE OPENER
J. ILAKKIA M.Sc., B.Ed., M.Phil. Computer Instructor Grade-I, GHSS – V.Pagandai, Villupuram.
return 1;
}
}
Output :
Enter a number to find its factorial: 5
Factorial of Number 5 = 120
3. What are the different forms of function return? Explain with example.
• Returning from the function is done by using the return statement.
• The return statement stops execution and returns to the calling function.
• When a return statement is executed, the function is terminated immediately at that point.
• A return may or may not have a value associated with it.
• If return has a value associated with it, that value becomes the return value for the calling statement.
• Even for void function return statement without parameter can be used to terminate the function.
Syntax:
return expression/variable;
Example :
return(a+b);
return(a);
return; // to terminate the function
Returning values:
• The functions that return no value is declared as void.
• The data type of a function is treated as int, if no data type is explicitly mentioned.
For Example :
int add (int, int);
add (int, int);
• In both prototypes, the return value is int, because by default the return value of a function is of type
int when no return value is explicitly given.
Returning Non-integer values:
• A string can also be returned to a calling statement.
Example :
#include<iostream>
#include<string.h>
using namespace std;
char *display()
{ return (“chennai”); }
int main()
{
char s[50];
strcpy(s,display());
cout<<”\nFunction with Non Integer Return”<<s;
return(0);}
Output :
47 Visit :http://www.youtube.com/c/CSKNOWLEDGEOPENER CS KNOWLEDGE OPENER
J. ILAKKIA M.Sc., B.Ed., M.Phil. Computer Instructor Grade-I, GHSS – V.Pagandai, Villupuram.
OUTPUT:
{
cout<<arr3[i][j]<<" ";
}
cout<<"\n";
}
return 0;
}
OUTPUT
7. Which of the following concept encapsulate all the essential properties of the object that are to be
created?
(A) class (B) Encapsulation (C) Polymorphism (D) Abstraction
8. Which of the following is the most important advantage of inheritance?
(A) data hiding (B) code reusability (C) code modification (D) accessibility
9. “Write once and use it multiple time” can be achieved by
(A) redundancy (B) reusability (C) modification (D) composition
10. Which of the following supports the transitive nature of data?
(A) Inheritance (B) Encapsulation (C) Polymorphism (D) Abstraction
Very Short Answers (2 Mark)
3. What is polymorphism?
• Polymorphism is the ability of a message or function to be displayed in more than one form.
4. How is encapsulation and abstraction are interrelated?
• Abstraction refers to showing only the essential features without revealing background details.
• Classes use the concept of abstraction to define a list of abstract attributes and function which operate
on these attributes.
• They encapsulate all the essential properties of the object that are to be created.
5. Write the disadvantages of OOP.
• Size:
• Object Oriented Programs are much larger than other programs.
• Effort:
• Object Oriented Programs require a lot of work to create.
• Speed:
• Object Oriented Programs are slower than other programs, because of their size.
Short Answers (3 Mark)
4. What do you mean by modularization and software reuse?
• Modularisation: Where the program can be decomposed into modules.
• Software re-use: Where a program can be composed from existing and new modules.
5. Define information hiding.
• Data and Functions are bound together into a single unit is known as Encapsulation.
• Encapsulation of data from direct access by the program is called data hiding or information hiding.
Explain in detail (5 Mark)
2. What are the advantages of OOPs?
a) Re-usability:
• “Write once and use it multiple times” you can achieve this by using class.
b) Redundancy:
• Inheritance is the good feature for data redundancy.
• If you need a same functionality in multiple class you can write a common class for the same
functionality and inherit that class to sub class.
c) Easy Maintenance:
• It is easy to maintain and modify existing code as new objects can be created with small differences to
existing ones.
d) Security:
• Using data hiding and abstraction only necessary data will be provided thus maintains the security of
data.
3 Write a note on the basic concepts that supports OOPs?
Main Features of Object Oriented Programming
Encapsulation
• Data and Functions are bound together into a single unit is known as Encapsulation.
• Encapsulation is about binding the data variables and functions together in class. It can also be called
data binding.
• Encapsulation of data from direct access by the program is called data hiding or information hiding.
Data Abstraction
• Abstraction refers to showing only the essential features without revealing background details.
• Classes use the concept of abstraction to define a list of abstract attributes and function.
• They encapsulate all the essential properties of the object that are to be created.
• The attributes are called data members because they hold information.
• The functions that operate on these data are called methods or member function.
Modularity
• Modularity is designing a system that is divided into a set of functional units (named modules) that can
be composed into a larger application.
Inheritance
• Inheritance is the technique of building new classes (derived class) from an existing Class (base
class).
• The most important advantage of inheritance is code reusability.
Polymorphism
• Polymorphism is the ability of a message or function to be displayed in more than one form.
14. CLASSES AND OBJECTS
Choose the correct answer (1 Mark)
1. The variables declared inside the class are known as
(A) data (B) inline (C) method (D) attributes
2. Which of the following statements about member functions are True or False?
i) A member function can call another member function directly with using the dot operator.
ii) Member function can access the private data of the class.
(A) i)True, ii)True (B) i)False, ii)True (C) i)True, ii)False (D) i)False, ii)False
3. A member function can call another member function directly, without using the dot operator
called as
(A) sub function (B) sub member (C) nesting of member function (D) sibling of member function
4. The member function defined within the class behave like ........ functions
(A) inline (B) Non inline (C) Outline (D) Data
5. Which of the following access specifier protects data from inadvertent modifications?
(A) Private (B) Protected (C) Public (D) Global
6. class x
{
int y;
public:
x(int z){y=z;}
} x1[4];
int main()
{ x x2(10);
return 0;}
How many objects are created for the above program
(A) 10 (B) 14 (C) 5 (D) 2
Very Short Answers (2 Mark)
1. What are called members?
• Class comprises of members called as Data Members and Member functions.
• Data members are the data variables that represent the features or properties of a class.
• Member functions are the functions that perform specific tasks in a class.
2. Differentiate structure and class though both are user defined data type.
• The only difference between structure and class is the members of structure are by default public
where as it is private in class.
3. What is the difference between the class and object in terms of oop?
Class Object
• A class is a template that represents a group of • An identifiable entity with some
objects that share common properties and characteristics and behaviour is called
relationship. object.
• Class is a way to bind the data and its • The class variables are called object or
associated functions together. instance of class.
Example: Example:
Class Stud Stud s;
“Stud” is a class “s” is a object of class Stud.
Short Answers (3 Mark)
1. Rewrite the following program after removing the syntax errors if any and underline the errors:
#include<iostream>
$include<stdio>
class mystud
{ int studid =1001;
char name[20];
public
mystud( ) { }
void register ( )
{cin>>stdid; gets(name); }
void display ( )
{cout<<studid<<”: “<<name<<endl;}
}
int main( )
{ mystud MS;
register.MS( );
MS.display( );
}
CORRECT CODE
#include<iostream>
#include<stdio.h>
using namespace std;
class mystud
{
int studid;
char name[20];
public:
mystud()
{
studid = 1001;
}
void reg()
{
cout<<"Enter the Name:";
gets(name);
cout<<"Student Id"<<'\t'<<"Name"<<'\n';
}
void display()
{ cout<<studid<<'\t'<<'\t'<<name<<endl;}
};
int main()
{
mystud MS;
MS.reg();
MS.display();
return 0;
}
OUTPUT
Public member:
GetInfo( ) /* Function to Read the information like name , room no, charges and days*/
DispInfo( ) /* Function to display all entered details and total amount calculated using COMPUTE
function*/
CODING
#include<iostream>
using namespace std;
class RESORT
{
private:
int Rno, Days, Charges;
char Rname[20];
int compute()
{
if( Days * Charges > 11000 )
return ( Days * Charges * 1.02 );
else
return ( Days * Charges);
}
public:
GetInfo()
{
cout<< "\n Enter customer name :";
cin>>Rname;
cout<< "\n Enter charges per day:";
cin>>Charges;
cout<< "\n Enter Number of days:";
cin>>Days;
cout<< "\n Enter Room Number:";
cin>>Rno;
}
DispInfo()
{
cout<< "\n Room Number:" <<Rno;
cout<< "\n Customer name:" <<Rname;
cout<< "\n Charges per day:" <<Charges;
cout<< "\n Number of days:" <<Days;
cout<< "\n Total Amount:" <<compute();
}
};
int main()
{
RESORT S;
S.GetInfo();
S.DispInfo();
}
OUTPUT:
cout<<"Roll no : "<<rno<<"\n";
cout<<"Marks : "<<marks<<endl;
}
};
int main()
{
student s(14,70);
s.printdet();
cout<< "Back to Main";
return 0;
}
OUTPUT
15. POLYMORPHISM
Choose the correct answer (1 Mark)
1. Which of the following refers to a function having more than one distinct meaning?
(A) Function Overloading (B) Member overloading
(C) Operator overloading (D) Operations overloading
2. Which of the following reduces the number of comparisons in a program?
(A) Operator overloading (B) Operations overloading
(C) Function Overloading (D) Member overloading
3. void dispchar(char ch=’$’,int size=10)
{
for(int i=1;i<=size;i++)
cout<<ch;
}
How will you invoke the function dispchar() for the following input?
To print $ for 10 times
(A) dispchar(); (B) dispchar(ch,size); (C) dispchar($,10); (D)dispchar(‘$’,10 times);
2. How does a compiler decide as to which function should be invoked when there are many
functions? Give an example.
• When you call an overloaded function, the compiler determines the most appropriate definition to use,
by comparing the argument types you have used to call the function with the parameter types specified
in the definitions.
• The process of selecting the most appropriate overloaded function or operator is called overload
resolution.
Example:
float area ( float radius);
float area ( float half, float base, float height );
float area ( float length , float breadth);
• The function “area” can be called using proper number of arguments in function call statement.
3. What is operator overloading? Give some examples of operators which can be overloaded.
• The term Operator overloading, refers to giving additional functionality to the normal C++ operators
like +,++,-,—,+=,-=,*.<,>.
• It is also a type of polymorphism in which an operator is overloaded to give user defined meaning to it
• For example '+' operator can be overloaded to perform addition on various data types, like for Integer,
String(concatenation) etc.
Explain in detail (5 Mark)
1. What are the rules for operator overloading?
1. Precedence and Associativity of an operator cannot be changed.
2. No new operators can be created, only existing operators can be overloaded.
3. Cannot redefine the meaning of an operator’s procedure. You cannot change how integers are added.
Only additional functions can be given to an operator
4. Overloaded operators cannot have default arguments.
5. When binary operators are overloaded, the left hand object must be an object of the relevant class
4. Answer the questions based on the following program
#include<iostream>
#include<string.h>
using namespace std;
class comp {
public:
char s[10];
void getstring(char str[10])
{ strcpy(s,str); }
void operator==(comp);
};
void comp::operator==(comp ob)
{ if(strcmp(s,ob.s)==0)
16. INHERITANCE
Choose the correct answer (1 Mark)
1. Which of the following is the process of creating new classes from an existing class
(a) Polymorphism (b) Inheritance (c) Encapsulation (d) super class
2. Which of the following derives a class student from the base class school
(a) school: student (b) class student : public school
(c) student : public school (d) class school : public student
3. The type of inheritance that reflects the transitive nature is
(A) Single Inheritance (B) Multiple Inheritance
(C) Multilevel Inheritance (D) Hybrid Inheritance
5. Inheritance is a process of creating new class from
(A) Base class (B) abstract (C) derived class (D) Function
6. A class is derived from a class which is a derived class itself, then this is referred to as
(A) multiple inheritance (B) multilevel inheritance
(C) single inheritance (D) double inheritance
Very Short Answers (2 Mark)
1. What is inheritance?
• The mechanism of deriving new class from an existing class is called inheritance.
2. What is a base class?
• A class that is used as the basis for creating a new class is called a super class or base class.
3. What is the difference between polymorphism and inheritance though are used for reusability
of code?
Polymorphism:
• Reusability of code is implemented through functions (or) methods.
• Polymorphism is the ability of a function to respond differently to different message.
• Polymorphism is achieved through function and operator overloading.
Inheritance:
• Reusability of code is implemented through classes.
• Inheritance is the process of creating derived classes from the base class or classes.
• Inheritance is achieved by various types of inheritances namely single, multiple, multilevel, hybrid and
hierarchical inheritances.
Explain in detail (5 Mark)
1. Explain the different types of inheritance
There are different types of inheritance viz., Single Inheritance, Multiple inheritance, Multilevel
inheritance, hybrid inheritance and hierarchical inheritance.
1. Single Inheritance
When a derived class inherits only from one base class, it is known as single inheritance
2. Multiple Inheritance
When a derived class inherits from multiple base classes it is known as multiple inheritance
3. Hierarchical inheritance
When more than one derived classes are created from a single base class , it is known as Hierarchical
inheritance.
4. Multilevel Inheritance
The transitive nature of inheritance is reflected by this form of inheritance. When a class is derived from a
class which is a derived class – then it is referred to as multilevel inheritance.
5. Hybrid inheritance
When there is a combination of more than one type of inheritance, it is known as hybrid inheritance.
Hence, it may be a combination of Multilevel and Multiple inheritance or Hierarchical and Multilevel
inheritance or Hierarchical, Multilevel and Multiple inheritance.
OUTPUT
• Most of the commercial software is licensed for use at a single computer site or for use by only one
user at any time.
• When a user buys any software, he becomes a licensed user for that software.
• He is allowed to make copies of the program for backup purposes, but it is against the law to distribute
duplicate copies to others.
• Such illegal copying and distribution of commercial software should not be practiced.
• An entirely different approach to software piracy is called shareware, acknowledges the futility of
trying to stop people from copying software and instead relies on people’s honesty.
• Shareware publishers encourage users to give copies of programs to friends and colleagues but ask
everyone who uses that program regularly to pay a registration fee to the program’s author directly.
• Commercial programs that are made available to the public illegally are often called warez.
PREVENTION:
• To pretend being your friend and talk to you on Internet Relay Chat(IRC) or by Instant messenger,
e-mail can also be a source for them.
• They may send official e-mail requesting some sensitive information.
18. TAMIL COMPUTING
Very Short Answers (2 Mark)
1. List the search engines supported by Tamil language.
• Google
• Bing
• Yahoo
2. What are the keyboard layouts used in Android?
• Sellinam and Ponmadal – are familiar Tamil keyboard layouts that works on Android operating system
in Smart phone using phonetics.
3. Write a short note about Tamil Programming Language.
• Programming languages to develop software in computers and smart phones are available only in
English.
• Based on Python programming language, the first Tamil programming language “Ezhil” (எ�ல் ) is
designed.
4. What is TSCII?
• TSCII (Tamil Script Code for Information Interchange) is the first coding system to handle our Tamil
language.
• This encoding scheme was registered in IANA (Internet Assigned Numbers Authority) a unit of
ICANN.
***
PREPARED BY