Samacheer Kalvi 9th Maths Guide Chapter 1 Set Language Ex 1.6

Students can download Maths Chapter 1 Set Language Ex 1.6 Questions and Answers, Notes, Samacheer Kalvi 9th Maths Guide Pdf helps you to revise the complete Tamilnadu State Board New Syllabus, helps students complete homework assignments and to score high marks in board exams.

Tamilnadu Samacheer Kalvi 9th Maths Solutions Chapter 1 Set Language Ex 1.6

Question 1.
(i) If n(A) = 25, n(B) – 40, n(A∪B) = 50 and n(B’) = 25, find n(A∩B) and n(U).
Solution:
Given, n(A) = 25, n(B) = 40, n(A∪B) = 50 and n(B’) = 25 n(A∩B) = n(A) + n(B) – n(A∪B)
n(A∩B) = n(A) + n(B) – n(A∪B)
n(A∩B) = 25 + 40 – 50
= 65 – 50
= 15
n(U) = n(B) + n(B)’
= 40 + 25
= 65
∴ n(A∩B) = 15 and n(U) = 65

(ii) If n(A) = 300, n(A∪B) = 500, n(A∩B) = 50 and n(B’) = 350, find n(B) and n(U).
Solution:
Given, n(A) = 300, n(A∪B) = 500, n(A∩B) = 50 and n(B’) = 350
n(A∪B) = n(A) + n(B) – n(A∩B)
500 = 300 + n(B) – 50
500 = 250 + n(B)
500 – 250 = n(B)
250 = n(B)
∴ n(B) = 250
n(U) = n(B) + n(B)’
250 + 350 = 600
∴ n(B) = 250 and n(U) = 600

Samacheer Kalvi 9th Maths Guide Chapter 1 Set Language Ex 1.6

Question 2.
If U = {x : x ∈ N, x ≤ 10}, A = { 2, 3, 4, 8, 10} and B = {1, 2, 5, 8, 10}, then verify that n(A∪B) = n(A) + n(B) – n(A∩B)
Solution:
U= {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
A = {2, 3, 4, 8, 10}; B = {1, 2, 5, 8, 10}
n(U) = 10, n(A) = 5, n(B) = 5
(A∪B) = {2, 3, 4, 8, 10} ∪ {1, 2, 5, 8, 10}
= {1, 2, 3, 4, 5, 8, 10}
∴ n(A∪B) = 7 ……..(1)
(A∩B) = {2, 3, 4, 8, 10} ∩ {1, 2, 5, 8, 10}
= {2, 8, 10}
n(A∩B) = 3
n(A) + n(B) – n(A∩B) = 5 + 5 – 3
= 10 – 3
= 7 ……(2)
From (1) and (2) we get,
n(A∪B) = n(A) + n(B) – n(A∩B)

Samacheer Kalvi 9th Maths Guide Chapter 1 Set Language Ex 1.6

Question 3.
Verify n(A∪B∪C) = n(A) + n(B) + n(C) – n(A∩B) – n(B∩C) – n(A∩C) + n(A∩B∩C) for the following sets.
(i) A = {a, c, e, f, h}, B = {c, d, e, f} and C = {a, b, c, f}
Solution:
A∩B = {a, c, e, f, h} ∩ {c, d, e, f}
= {c, e, f}
B∩C = {c, d, e, f} ∩ {a, b, c, f}
= {c, f}
A∩C = {a, c, e, f, h} ∩ {a, b, c, f}
= {c, f}
(A∩B∩C) = {a, c, e, f, h} ∩ {c, d, e, f} ∩ {a, b, c, f}
= {c, f}
(A∪B∪C) = {a, c, e, f, h} ∪ {c, d, e, f} ∪ {a, b, c, f}
= {a, b, c, d, e, f, h}
n(A∩B) = 3, n(B∩C) = 2, n(A∩C) = 3, n(A∩B∩C) = 2
n(A∪B∪C) = 7……….(1)
n(A) + n(B) + n(C) – n(A∩B) – n(B∩C) – n( A∩C) + n(A∩B∩C)
= 5 + 4 + 4 – 3 – 2 – 3 + 2 = 15 – 8
= 7 ……….(2)
From (1) and (2) we get
n(A∪B∪C) = n(A) + n(B) + n(C) – n(A∩B) – n(B∩C) – n(A∩C) + n(A∩B∩C)

(ii) A= {1, 3, 5}, B = {2, 3, 5, 6}, C = {1, 5, 6, 7}
A∩B = {1, 3, 5} ∩ {2, 3, 5, 6}
= {3, 5}
B∩C = {2, 3, 5, 6} ∩ {1, 5, 6, 7}
= {5, 6}
A∩C = {1, 3, 5} ∩ {1, 5, 6, 7}
= {1, 5}
A∩B∩C = {1, 3, 5} ∩ {2, 3, 5, 6} ∩ {1, 5, 6, 7}
= {5}
A∪B∪C = {1, 3, 5} ∪ {2, 3, 5, 6} ∪ {1, 5, 6, 7}
= {1, 2, 3, 5, 6, 7}
n(A) = 3, n(B) = 4, n(C) = 4
n(A∩B) = 2, n(B∩C) = 2, n(A∩C) = 2
n(A∩B∩C) = 1
n(A∪B∪C) = 6……….(1)
n(A) + n(B) + n(C) – n(A∩B) – n(B∩C) – n(A∩C) + n(A∩B∩C) = 3 + 4 + 4 – 2 – 2 – 2 + 1
= 12 – 6
= 6………(2)
From (1) and (2) we get
n(A∪B∪C) = n(A) + n(B) + n(C) – n(A∩B) – n(B∩C) – n(A∩C) + n(A∩B∩C)

Samacheer Kalvi 9th Maths Guide Chapter 1 Set Language Ex 1.6

Question 4.
In a class, all students take part in either music or drama or both. 25 students take part in music, 30 students take part in drama and 8 students take part in both music and drama. Find
(i) The number of students who take part in only music.
(ii) The number of students who take part in only drama.
(iii) The total number of students in the class.
Solution:
Samacheer Kalvi 9th Maths Guide Chapter 1 Set Language Ex 1.6 1
Let M be the set of all students take part in music.
Let D be the set of all students take part in drama.
n( M) = 25, n(D) = 30 and n(M∩D) = 8
By using venn-diagram
From the venn – diagram we get.
(i) Number of students take part in only music = 17
(ii) Number of students take part in only drama = 22
(iii) Total number of students in the class = 17 + 8 + 22 = 47

Question 5.
In a party of 45 people, each one likes Tea or Coffee or both. 35 people like tea and 20 people like coffee. Find the number of people who
(i) like both Tea and Coffee.
(ii) do not like Tea.
(iii) do not like Coffee.
Solution:
Samacheer Kalvi 9th Maths Guide Chapter 1 Set Language Ex 1.6 2
Let’T’ be the set of people likes Tea
Let ‘C’ be the set of people likes Coffee
n(T∩C) = 45, n(T) = 35 and n(C) = 20
Let X be the number of people likes both Tea and Coffee.
By using venn diagram
From the venn – diagram we get.
35 – x + x + 20 – x = 45
55 – x = 45
55 – 45 = x
10 = x
(i) People like both tea and coffee = 10
(ii) People do not like tea = 20 – x
= 20 – 10 = 10
(iii) People do not like coffee = 35 – x
= 35 – 10 = 25

Samacheer Kalvi 9th Maths Guide Chapter 1 Set Language Ex 1.6

Question 6.
In an examination 50% of the students passed in mathematics and 70% of students passed in science while 10% students failed in both subjects. 300 students passed in both the subjects. Find the total number of students who appeared in the examination, if they took examination in only two subjects.
Solution:
Let M and S represent the student failed in Mathematics and Science.
Given: Number of students passed in Mathematics is 50%
Samacheer Kalvi 9th Maths Guide Chapter 1 Set Language Ex 1.6 3
∴ Number of students failed in Mathematics = 100 – 50% = 50%
n(M) = 50%
Number of students passed in Science is 70%
∴ Number of students failed in Science = 100 – 70% = 30%
n(S) = 30%
Number of students failed in both the subjects is 10%
n(M∩S) = 10%
n(M∪S)= n(M) + n(S) – n(M∩S)
= 50 + 30 – 10 = 80 – 10 = 70
Given: 70% of the students failed in atleast any one of the subject
∴ 30% of the students passed in atleast any one of the subjects.
30 students passed mean, the total number of students is 100.
∴ 300 students passed means, the total number of students = \(\frac{100 × 300}{30}\)
Total number of students appeared in the examination = 1000

Question 7.
A and B are two sets such that n(A – B) = 32 + x, n(B – A) = 5x and n(A∩B) = x. Illustrate the information by means of a venn diagram. Given that n(A) = n(B). Calculate the value of x.
Solution:
n(A – B) = 32 + x, n(B – A) = 5x
n(A∩B) = x
From the Venn diagram:
Samacheer Kalvi 9th Maths Guide Chapter 1 Set Language Ex 1.6 4
Given n( A) = n(B)
32 + x + x = x + 5x
32 + 2x = 6x
32 = 6x – 2x
32 = 4x
x = \(\frac{32}{4}\) = 8
The value of x = 8

Samacheer Kalvi 9th Maths Guide Chapter 1 Set Language Ex 1.6

Question 8.
Out of 500 car owners investigated, 400 owned car A and 200 owned car B, 50 owned both A and B cars. Is this data correct?
Solution:
Let A be the set of people owned car A
Let B be the set of people owned car B
n( A) = 400, n(B) = 200, n(A∩B) = 50
n(A∪B) = 500………..(1)
n(A) + n(B) – n(A∩B) = 400 + 200 – 50
= 600 – 50
= 550………(2)
From (1) and (2) we get
n(A∪B) ≠ n(A) + n(B) – n(A∩B)
∴ The given data is not correct.

Question 9.
In a colony, 275 families buy Tamil newspaper, 150 families buy English newspaper, 45 families buy Hindi newspaper, 125 families buy Tamil and English newspapers, 17 families buy English and Hindi newspapers, 5 families buy Tamil and Hindi newspapers and 3 families buy all the three newspapers. If each family buy atleast one of these newspapers then find
(i) Number of families buy only one newspaper
(ii) Number of families buy atleast two newspapers
(iii) Total number of families in the colony.
Solution:
Let T, E and H represent families buying Tamil newspaper, English newspaper and Hindi newspaper respectively.
n(T) = 275, n(E) = 150, n(H) = 45
n(T∩E) = 125, n(E∩H) = 17, n(T∩H) = 5
n(T∩E∩H) = 3
Let us represent the given data in Venn diagrams.
Samacheer Kalvi 9th Maths Guide Chapter 1 Set Language Ex 1.6 5
(i) Number of families buy only one news paper = 148 + 11 + 26
= 185
(ii) Number of families buy atleast two news paper = 122 + 2 + 14 + 3
= 141
(iii) Total number of families in the colony = 148 + 122 + 11 + 14 + 3 + 2 + 26
= 326

Samacheer Kalvi 9th Maths Guide Chapter 1 Set Language Ex 1.6

Question 10.
A survey of 1000 farmers found that 600 grew paddy, 350 grew ragi, 280 grew corn, 120 grew paddy and ragi, 100 grew ragi and corn, 80 grew paddy and corn. If each farmer grew atleast any one of the above three, then find the number of farmers who grew all the three.
Solution:
Let P, R and C represent sets of farmers grew paddy, ragi and com respectively.
n(P∪R∪C) = 1000, n(P) = 600, n(R) = 350, n(C) = 280
n(P∩R) = 120, n(R∩C) = 100, w(P∩C) = 80 Let the number of farmers who grew all the three be “x”
n(P∪R∪C ) = n(P) + n( R) + n( C) – n(P∩R) – n(R∩C) – n(P∩C) + n(P∩R∩C )
1000 = 600 + 350 + 280 – 120 – 100 – 80 + x = 1230 – 300 + x.
1000 = 930 + x
1000 – 930 = x
70 = x
Number of farmers who grew all the three = 70.

Question 11.
In the adjacent diagram, if n(U) = 125, y is two times of x and z is 10 more than x, then find the value of x, y and z.
Samacheer Kalvi 9th Maths Guide Chapter 1 Set Language Ex 1.6 6
Solution:
n(U) = 125
y = 2x and z = x + 10
n(U) = x + 4 + y + 17 + 3 + 6 + z + 5
125 = x + 4 + 2x + 17 + 3 + 6 + x + 10 + 5
125 = 4x + 45
125 – 45 = 4x
80 = 4x
x = 80/4 = 20
y = 2x = 2 × 20 = 40
z = x + 10 = 20 + 10 = 30
∴ The value of x = 20, y = 40 and z = 30.

Samacheer Kalvi 9th Maths Guide Chapter 1 Set Language Ex 1.6

Question 12.
Each student in a class of 35 plays atleast one game among chess, carrom and table tennis. 22 play chess, 21 play carrom, 15 play table tennis, 10 play chess and table tennis, 8 play carrom and table tennis and 6 play all the three games. Find the number of students who play (i) chess and carrom but not table tennis (ii) only chess (iii) only carrom (Hint: Use Venn diagram)
Solution:
Let A, B and C represent students play chess, carrom and table tennis.
n(A) = 22, n(B) = 21 , n(C) = 15
n(A∩C) = 10 , n(B∩C) = 8 , n(A∩B∩C) = 6
Let “x” represent student play chess and carrom but not table tennis.
Let us represent the data in Venn diagram.
Samacheer Kalvi 9th Maths Guide Chapter 1 Set Language Ex 1.6 7
From the Venn diagram we get,
Number of students play atleast one game = 35
12 – x + x + 13 – x + 2 + 6 + 4 + 3 = 35
40 – 35 = x
5 = x
(i) Number of students who play chess and carrom but not table tennis = 5
(ii) Number of students who play only chess = 12 – x
= 12 – 5 = 7
(iii) Number of students who play only carrom = 13 – x
= 13 – 5 = 8

Question 13.
In a class of 50 students, each one come to school by bus or by bicycle or on foot. 25 by bus, 20 by bicycle, 30 on foot and 10 students by all the three. Now how many students come to school exactly by two modes of transport?
Solution:
Let B, C and D represent students come to school by bus, bicycle and foot respectively.
n(B∪C∪D) = 50 , n(B) = 25 , n(C) = 20 , n(D) = 30, n(B∩C∩D) = 10
Let x, y and z represent the students come to school exactly by two modes of transport.
Let us represent the given data in Venn diagrams.
<Samacheer Kalvi 9th Maths Guide Chapter 1 Set Language Ex 1.6 8
Total number of students in the class = 50
15 – x – z + x + 10 – x – y + y + 10 + z + 20 – z – y = 50
55 – x – y – z = 50
55 – 50 = x + y + z
5 = x + y + z
Number of students come to school exactly by two modes of transport = 5

Samacheer Kalvi 9th Maths Guide Chapter 1 Set Language Ex 1.6

Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions

Students can download Maths Chapter 1 Relations and Functions Additional Questions and Answers, Notes, Samacheer Kalvi 10th Maths Guide Pdf helps you to revise the complete Tamilnadu State Board New Syllabus, helps students complete homework assignments and to score high marks in board exams.

Tamilnadu Samacheer Kalvi 10th Maths Solutions Chapter 1 Relations and Functions Additional Questions

I. Multiple Choice Questions.

Question 1.
If n(A × B) = 15 and B = {1, 3, 7} then n(A) is ……………
(1) 3
(2) 5
(3) 1
(4) 15
Answer:
(2) 5
Hint: B(A × B) = 15
n(A) × n(B) = 15
n(A) × 3 = 15
n(A) = \(\frac { 15 }{ 3 } \) = 5

Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions

Question 2.
If A = {a, b,c) B = {b, d, e}
C = {a, e, i, o, u} then n [A ∩ C] × B] is
(1) 18
(2) 36
(3) 9
(4) 3
Answer:
(4) 3
Hint:
A ∩ C = {a,b,c} ∩ {a, e, i, o, u}
= {a}
n(A ∩ C) = 1
n[(A ∩ C) × B] = n(A ∩ C) × n(B)
= 1 × 3
= 3

Question 3.
If there are 28 relation from a set A = {2,4, 6, 8} to a set B, then the number of elements in B is ………………
(1) 7
(2) 14
(3) 5
(4) 4
Answer:
(1) 7
Hint: n(A) = 4
n(A × B) = 28
n(A) × n(B) = 28
4 × n(B) = 28
n(B) = \(\frac { 28 }{ 4 } \) = 7

Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions

Question 4.
The ordered pairs (a + 1, 4) (3, 4a + b) are equal then (a, b) is ………………..
(1) (4, 20)
(2) (20, 4)
(3) (-4, 20)
(4) (20, -4)
Answer:
(3) (-4, 20)
Hint: (a + 7, 4) = (3, 4a + b)
a + 7 = 3
a = 3 – 7
= – 4
4a + b = 4
4(-4) + b = 4
-16 + b = 4
b = 4 + 16 = 20
The pair (a, 6) is (-4, 20)

Question 5.
The range of the relation R = {(x, x3) / x} is a prime number less than 13} is …………………
(1) (2,3,5,7,11)
(2) (4,9,25,49,121)
(3) (8,27, 125,343, 1331)
(4) (1,8,27, 125,343, 1331)
Answer:
(3) (8, 27, 125,343, 1331)
Hint: x = {2, 3, 5, 7, 11}
Range (x3) = {8, 27, 125, 343, 1331}

Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions

Question 6.
If {( x, 2), (4, y) } represents an identity function, then (x, y) is
(1) (2, 4)
(2) (4, 2)
(3) (2, 2)
(4) (4, 4)
Answer:
(1) (2, 4)
Hint: In an identity function each element is associated with itself.

Question 7.
If {(7, 11), (5, a)} represents a constant
function, then the value of ‘a’ is
(1) 7
(2) 11
(3) 5
(4) 9
Answer:
(2) 11
Hint: All the images are same in a constant function.

Question 8.
Given f(x) = (- 1)x is a function from N to Z. Then the range of f is
(1) {1}
(2) N
(3) { 1,- 1 }
(4) Z
Answer:
(3) {1, – 1}
Hint: f(x) = (- 1)x = ± 1

Question 9.
If f = { (6, 3), (8, 9), (5, 3), (-1, 6) }, then the pre-images of 3 are
(1) 5 and-1
(2) 6 and 8
(3) 8 and-1
(4) 6 and 5
Answer:
(4) 6 and 5.
Hint: The Pre images of 3 are 6 and 5

Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions

Question 10.
Let A= { 1, 3, 4, 7, 11 }, B = {-1, 1, 2, 5, 7, 9 } and f : A → B be given by
f = {(1, -1), (3,2), (4, 1), (7, 5), (11, 9)}.
Then f is ………………….
(1) one-one
(2) onto
(3) bijective
(4) not a function
Answer:
(1) one – one
Hint:
Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions 1

Question 11.
The given diagram represents
(1) an onto function
(2) a constant function
(3) an one-one function
(4) not a function
Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions 2
Answer:
(4) not a function
Hint: 2 has two images 4 and 2.
It is not a function.

Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions

Question 12.
If A = { 5, 6, 7 }, B = { 1, 2, 3, 4, 5 }and f: A → B is defined by f(x) = x – 2, then the range of f is …………….
(1) {1,4, 5}
(2) {1,2, 3, 4, 5}
(3) { 2, 3, 4 }
(4) { 3, 4, 5 }
Answer:
(4) {3, 4, 5}
Hint: f(x) = x – 2
f(5) = 5 – 2 = 3
f(6) = 6 – 2 = 4
f(7) = 7 – 2 = 5
Range of f = {3, 4, 5}

Question 13.
If f(x) = x2 + 5, then f(-4) = ………
(1) 26
(2) 21
(3) 20
(4) – 20
Answer:
(2) 21
Hint: f(x) = x2 + 5
f(- 4) = (-4)2 + 5 = 16 + 5 = 21

Question 14.
If the range of a function is a singleton set, then it is ……………..
(1) a constant function
(2) an identity function
(3) a bijective function
(4) an one-one function
Answer:
(1) a constant function
Hint: Every element of the first set has same image in the second set.

Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions

Question 15.
If f : A → B is a bijective function and if n(A) = 5 , then n(B) is equal to ………………
(1) 10
(2) 4
(3) 5
(4) 25
Answer:
(3) 5
Hint: If A and B are Bijective (one-one and onto) function then n (A) = n (B)

Question 16.
If f: R → R defined by f(x) = 3x – 6 and g : R → R defined by g(x) = 3x + k if fog – gof then the value of k is …………………..
(1) – 5
(2) 5
(3) 6
(4) -6
Answer:
(4) – 6
Hint: f(x) = 3x – 6 ;g(x) = 3x + k
fog = f[g(x)]
= f(3x + k)
= 3 (3x + k) – 6
= 9x + 3k – 6
g o f = g[f(x)]
= g(3x – 6)
= 3(3x – 6 ) + k
= 9x – 18 + k
But fog = gof
9x + 3k – 6 = 9x – 18 + k
3k – k = -18 + 6
2k = -12
k = \(\frac { -12 }{ 2 } \) = -6

Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions

Question 17.
If f(x) = x2 – x then f (x – 1) – f(x + 1) is ……………….
(1) 4x
(2) 4x + 2
(3) 2 – 4x
(4) 4x – 2
Answer:
(3) 2 – 4x
Hint: f(x – 1) = (x – 1)2 – (x – 1)
= x2 – 2x + 1 – x + 1
= x2 – 3x + 2
f(x + 1) = (x + 1)2 – (x + 1)
= x2 + 2x + 1 – x – 1
= x2 + x
f(x – 1) – f(x + 1) = x2 – 3x + 2 – (x2 + x)
= x2 – 3x + 2 – x2 – x
= -4x + 2 = 2 – 4x

Question 18.
If K(x) = 3x – 9 then L (x) = 7x – 10 then LOK is ……………..
(1) 21x + 73
(2) – 21x + 73
(3) 21x – 73
(4) 22x – 73
Answer:
(3) 21x – 73
Hint: K (x) = 3x – 9 ; L(x) = 7x – 10
LOK = L[K(x)]
= L (3x – 9)
= 7(3x – 9) – 10
= 21x – 63 – 10
= 21x – 73

Question 19.
Composition of function is ……………..
(1) commutative
(2) associative
(3) commutative and associative
(4) not associative
Answer:
(2) associative

Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions

Question 20.
A comet is heading for Jupiter with acceleration a = 50 kms-2. The velocity of the comet at time ”t” is given by f(t) = at2 – at + 1. Then the velocity at time t = 5 seconds is …………..
(1) 900kms-1
(2) 1001 kms-1
(3) 2001 kms-1
(4) 50 kms-1
Answer:
(2) 1001 kms-1
Hint: f(t) = at2 – at + 1
m = 50(5)2 – 50(5) + 1
= 1250 – 250 + 1
= 1001 kms-1

II. Answer the following questions.

Question 1.
f(x) = (1 + x)
f(x) = (2x – 1)
Show that fo(g(x)) = gof(x)
Solution:
f(x) = 1 + x
g(x) = (2x – 1)
fog(x) = f(g(x)) = f(2x – 1)
= 1 + 2x – 1 = 2x ………….. (1)
gof(x) = g(f(x)) = g(1 + x) = 2(1 + x) = 1
= 2 + 2x – 1
= 2x + 1 ……………. (2)
(1) ≠ (2)
∴ fog(x) + gof(x) It is verified.

Question 2.
If A × B = {(a, x) (a, y) (b, x) (b, y) (c, x) (c, y)} then find A and B
Answer:
A × B = {(a, x) (a, y) (b, x) (b, y) (c, x) (c, y)}
A = {a, b, c}
B = {x,y}

Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions

Question 3.
Let A = {x ∈ w/3 < x < 7},
B = {x ∈ N/0 < x < 3}, C = {x ∈ w/x < 2}
verify A × (B ∩ C) = (A × B) ∩ (A × C)
Answer:
A = {4,5,6} ; B = {1,2} C = {0, 1}
B ∩ C = {1,2} ∩ {0, 1}
= {1}
A × (B ∩ C) = {4,5,6} × {1}
= {(4, 1) (5, 1) (6, 1)} …. (1)
A × B = {4,5,6} × {1,2}
= {(4, 1) (4, 2) (5, 1) (5, 2) (6, 1) (6, 2)}
A × C = {4,5,6} x {0, 1}
= {(4,0) (4,1) (5,0)
(5, 1) (6, 0) (6, 1)}
(A × B) ∩ (A × C) = {(4, 1) (5, 1) (6, 1)}…. (2)
From (1) and (2) we get
A × (B ∩ C) = (A × B) ∩ (A × C)

Question 4.
Let A = {10, 11, 12, 13, 14}; B = {0, 1, 2, 3, 5} and fi: A → B, i = 1, 2, 3. State the type of function for the following (give reason):
(i) f1 = {(10,1), (11,2), (12,3), (13,5), (14,3)}
Answer:
The element 12 and 14 in A have same image 3 in B.
Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions 4
∴ It is not one-one function.
The element ‘0’ in B has no preimage in A
∴ It is not onto function
So the given function is neither one – one nor onto function.

Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions

(ii) f2 = {(10,1), (11,1), (12,1), (13,1), (14,1)}
Answer:
f2 is a constant function
Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions 3
(iii) f3 = {(10,0), (11,1), (12,2), (13,3), (14,5)}
Answer:
f3 is one-one and onto function (or) bijective function.
Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions 44

Question 5.
If X = {1, 2, 3, 4, 5}, Y = {1, 3, 5, 7, 9} determine which of the following relations from X to Y are functions? Give reason for your answer. If it is a function, state its type.
(i) R1 = {(x,y)| y = x + 2,x ∈ X,y ∈ Y}
Answer:
Given y = x + 2
When x = 1 ; y = 1 + 2 = 3
When x = 2 ; y = 2 + 2 = 4
When x = 3 ; y = 3 + 2 = 5
When x = 4 ; y = 4 + 2 = 6
When x = 5 ; y = 5 + 2 = 7
Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions 5
R1 = {1,3), (2,4), (3, 5), (4, 6), (5,7)}
R1 is not a function ; 2 and 4 has no image in Y.

Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions

(ii) R2 = {(1,1), (2,1), (3,3), (4,3), (5,5)}
Answer:
R2 is a function.
Every element of X has unique image in Y.
1 and 2 have same image 1
3 and 4 have same image 3
It is not one – one function …. (1)
7 and 9 has no pre image in X
It is not an onto function …. (2)
Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions 6
From (1) and (2) we know that, it is
neither one – one nor onto function.

(iii) R3 = {(1,1), (1,3), (3,5), (3,7), (5,7)}
Answer:
R3 is not a function.
1 has two images 1 and 3
3 has two images 5 and 7
Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions 7

(iv) R4 = {(1,3), (2,5), (4,7), (5,9), (3,1)}
Answer:
Every element of X has unique image in
Y. Range = Co-domain
R4 is a function.
Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions 8
It is an one-one and onto function (or) bijective function

Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions

Question 6.
A= {-2,-1, 1, 2} and f = {(x,\(\frac { 1 }{ x } \)) ; x ∈ A}
Write down the range of f. Is f a function from A to A?
Answer:
Given, f = (x,\(\frac { 1 }{ x } \)) ; So f(x) = \(\frac { 1 }{ x } \)
f (-2) = \(\frac { 1 }{ -2 } \) = – \(\frac { 1 }{ 2 } \) ; f(-1) = \(\frac { 1 }{ -1 } \) = -1
f(1) = \(\frac { 1 }{ 1 } \) = 1 ; f(2) = \(\frac { 1 }{ 2 } \) = \(\frac { 1 }{ 2 } \)
Range of f = {\(\frac { -1 }{ 2 } \), -1, 1, \(\frac { 1 }{ 2 } \)}
It is not a function from A to A since – \(\frac { 1 }{ 2 } \) ,\(\frac { 1 }{ 2 } \) ∈ A

Question 7.
Let A = {1, 2, 3, 4, 5}, B = N and f: A → B be defined by f(x) = x2. Find the range of f. Identify the type of function.
Solution:
A = {1, 2, 3, 4, 5}
B = {1, 2, 3, 4 ….}
f: A → B, f(x) = x2
∴ f(1) = 12 = 1
f(2) = 22 = 4
f(3) = 32 = 9
f(4) = 42 = 16
f(5) = 52 = 25
∴ Range of f = {1, 4, 9, 16, 25)
Elements in A have been different elements in B. Therefore it is one-one function. But not all the elements in B have preimages in A. Therefore it is not on-to function.

Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions

Question 8.
Let A = { 1, 2, 3, 4, 5 }, B = N and f: A → B be defined by f(x) = x2.
Find the range of f. Identify the type of function.
Answer:
Now, A = { 1, 2, 3, 4, 5 };
B = { 1, 2, 3, 4, … }
Given f: A → B and f(x) = x2
f(1) = 12 = 1;
f(2) = 4;
f(3) = 9;
f(4) = 16;
f(5) = 25.
Range of f = {1, 4, 9, 16, 25}
Since distinct elements are mapped into distinct images, it is a one-one function.
However, the function is not onto, since 3 ∈ B but there is no x ∈ A
such that
f(x) = x2 = 3.

Question 9.
Identify the type of function.
Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions 9
Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions 10
Answer:
(i) Many – one into
(ii) One – one onto
(iii) Constant function
(iv) One – one into

Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions

Question 10.
Find the domain and range of the following
(i) f = {(1, 2), (2, 3), (3, 4), (4, 5) (5, 6)}
(ii) R = {(-2, 4), (-1,1), (2,4), (1,1) (-3, 9)}
Answer:
(i) f = {( 1,2), (2, 3), (3, 4), (4, 5) (5, 6)}
Domain = {1,2, 3,4, 5}
Range = {2, 3, 4, 5, 6}

(ii) R = {(-2,4), (-1, 1),(2,4), (1,1) (-3,9)}
Domain = {-2, -1,2, 1,-3} (or)
= {-3,-2,-1, 1,2}
Range = {4, 1, 9} (or) {1, 4, 9}

Question 11.
Given P ={-2,-1, 0,1}
Q = {1,-2, 6,-3}
R = {x,y/y = x2 – 3 x ∈ P,y ∈ Q}
(i) List the elements of R
(ii) Is the relation a function? If so identity the function
Answer:
P = {-2, -1, 0, 1}; Q = {1, -2,6, -3}
y = x2- 3 x ∈ P, y ∈ Q
When x = -2 ⇒ y = (-2)2 – 3 = 4 – 3 = 1
When x = -1 ⇒ y = (-1 )2 – 3 = 1 – 3 = -2
When x = 0 ⇒ y = (0)2 – 3 = 0 -3 = -3
When x = 1 ⇒ y = 12 – 3 = 1 – 3 = -2
(i) R = {(-2,1), (-1,-2), (0,-3), (1,-2)}
(ii) Yes the relation is a function many – one into function.

Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions

Question 12.
Given f(x) = 3x – 2; g(x) = 2x2 find
(i) fog and
(ii) gof what do you find
Answer:
f(x) = 3x – 2 ; g(x) = 2x2
(i) f o g = f[g(x)]
= f(2x2)
= 3(2x2) – 2
= 6x2 – 2

(ii) g o f = g [f(x)]
= g (3x – 2)
= 2(3x – 2)2
= 2(9x2 + 4 – 12x)
= 18x2 – 24x + 8
we find that fog ≠ gof
Composition of function is not commutative.

Question 13.
If f: R → R is defined by f(x) = ax + 3 and g: R → R is defined by g (x) = 4x – 3 find a so that fog = gof
Answer:
f(x) = ax + 3 ; g(x) = 4x -3
fog = f[g(x)]
= f(4x – 3)
= a (4x – 3) + 3
= 4ax – 3a + 3
gof = g [f(x)]
= g (ax + 3)
= 4 (ax + 3) – 3
= 4 ax + 12 – 3
= 4ax + 9
But fog = gof
4ax – 3a + 3 = 4ax + 9
-3a + 3 = 9
– 3a = 6
a = – 2
The value of a = – 2

Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions

Question 14.
Given f(x) = 3 + x ; g(x) = x2 ;
h(x) = \(\frac { 1 }{ x } \) find fo (goh)
Answer:
f(x) = 3 + x ; g (x) = x2, h(x) = \(\frac { 1 }{ x } \)
goh = g[h(x)]
= g (\(\frac { 1 }{ x } \))
= (\(\frac { 1 }{ x } \))2
goh = \(\frac{1}{x^{2}}\)
fo(goh) = f (\(\frac{1}{x^{2}}\))
= 3 + \(\frac{1}{x^{2}}\)

Question 15.
If f(x) = x + 3 where A = {4, 6, 8,10} B = {7, 9,11,13} and f: A → B
(i) Draw the arrow diagram
(ii) Why type of function is f.
Answer:
A= {4, 6, 8, 10}
f(x) = x + 3
f(4) = 4 + 3 = 7
f(6) = 6 + 3 = 9
f(8) = 8 + 3 = 11
f(10) = 10 + 3 = 13
Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions 11
(ii) one – one onto function

III. Answer the following Questions

Question 1.
Given A = {2,3, 5}, B = {1,2,3}
C = {2, 5}, D = {2,3, 5} check if
(A ∩ C) × (B ∩ D) = (A × B) ∩ (C × D)
Answer:
A ∩ C = {2, 3, 5} ∩ (2, 5}
= (2,5}
B ∩ D = {1,2,3} ∩ {2,3,5}
= {2,3}
(A ∩ C) × (B ∩ D) = {2, 5} × {2, 3}
= {(2, 2) (2, 3) (5, 2) (5, 3)} …. (1)
A × B = {2,3,5} × {1,2,3}
= {(2,1) (2, 2) (2, 3)
(3, 1) (3, 2) (3, 3)
(5, 1) (5, 2) (5, 3)}
C × D = {2, 5} × {2, 3, 5}
= {(2, 2) (2, 3) (2, 5) (5, 2) (5, 3) (5, 5)}
(A × B) ∩ (C × D) = {(2,2) (2, 3) (5, 2) (5, 3)} …. (2)
From (1) and (2) we get
(A ∩ C) × (B ∩ D) = (A × B) ∩ (C × D)

Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions

Question 2.
Study the relation given below an set- builder form. Represent each of them by
(a) an arrow diagram
(b) a graph
(c) a set in roster.
If {{x,y}/y = 2x + 1; x < 10 and y < 12 x ∈ N, y ∈ N}
Answer:
y = 2x + 1
when x = 1 ⇒ y = 2(1) + 1 = 2 + 1 = 3
when x = 2 ⇒ y = 2(2) + 1 = 4 + 1 = 5
when x = 3 ⇒ y = 2(3) + 1 = 6 + 1 = 7
when x = 4 ⇒ y = 2(4) + 1 = 8 + 1 = 9
when x = 5 ⇒ y = 2(5) + 1 = 10 + 1 = 11
f = {(1,3) (2, 5) (3, 7) (4, 9) (5, 11)}

(a) Arrow diagram
Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions 12
(b) A graph
Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions 13
(c) Roster form: R = {(1,3) (2,5) (3,7) (4,9) (5,11)}

Question 3.
State whether the following graphs represents a function. Give reason for your answer.
Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions 14
Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions 15
Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions 16
Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions 17
Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions 18
Answer:
(i) The given graph represents a function. The vertical line cuts the graph at most one point R
Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions 19
(ii) The vertical line cuts the graph at most one point Q. The given graph represents a function.
Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions 20
(iii) The vertical line cuts the graph at A and B. The given graph does not represents a function.
Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions 21
(iv) The vertical line cuts the graph at A and B. The given graph does not represents a function.
Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions 22
(v) The vertical line cuts the graph at most one point R. The given graph represents a function.
Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions 23

Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions

Question 4.
Let A = {6, 9,15,18, 21}; B = {1, 2, 4, 5, 6} and f: A → B be defined by f(x) = \(\frac { x-3 }{ 3 } \) Represent f by, (i) an arrow diagram, (ii) a set of ordered pairs, (iii) a table, (iv) a graph.
Given, A = {6, 9, 15, 18, 21}, B = {1, 2, 4, 5, 6}
f(x) = \(\frac { x-3 }{ 3 } \)
f(6) = \(\frac { 6-3 }{ 3 } \) = \(\frac { 3 }{ 3 } \) = 1
f(9) = \(\frac { 9-3 }{ 3 } \) = \(\frac { 6 }{ 3 } \) = 2
f(15) = \(\frac { 15-3 }{ 3 } \) = \(\frac { 12 }{ 3 } \) = 4
f(18) = \(\frac { 18-3 }{ 3 } \) = \(\frac { 12 }{ 3 } \) = 4
f(18) = \(\frac { 18-3 }{ 3 } \) = \(\frac { 15 }{ 3 } \) = 5
f(21) = \(\frac { 21-3 }{ 3 } \) = \(\frac { 18 }{ 3 } \) = 6

(i) an arrow diagram
Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions 24
(ii) a set of ordered pairs
f = {(6,1), (9, 2), (15, 4), (18, 5), (21,6)}

(iii) a table
Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions 25

(iv) a graph
Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions 26

Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions

Question 5.
Let A = {4,6,8,10} and B = {3,4,5,6,7}. If f: A → B is defined by f(x) = \(\frac { 1 }{ 2 } \) x + 1 then represent f by (i) an arrow diagram, (ii) a set of ordered pairs and, (iii) a table.
Answer:
Given, A = {4, 6, 8, 10}
B = {3, 4, 5, 6, 7}
f(x) = \(\frac { x }{ 2 } \) + 1
f(4) = \(\frac { 4 }{ 2 } \) + 1 = 2 + 1 = 3
f(6) = \(\frac { 6 }{ 2 } \) + 1 = 3 + 1 = 4
f(8) = \(\frac { 8 }{ 2 } \) + 1 = 4 + 1 = 5
f(10) = \(\frac { 10 }{ 2 } \) + 1 = 5 + 1 = 6

(i) an arrow diagram
Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions 27
(ii) a set of ordered pairs
f = {(4, 3), (6, 4), (8, 5), (10, 6)}

(iii) a table
Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions 28

Question 6.
A function f[- 3, 7 ) → R is defined as follows f(x) =
Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions 29
Find (i) f(5) + f(6)
(ii) f(1) – f(-3)
(iii) f(-2) – f(4)
(iv) \(\frac{f(3)+f(-1)}{2 f(6)-f(1)}\)
Answer:
Given, f(x) = 4x2 – 1; x = {-3, -2, -1, 0, 1}
f(x) = 3x – 2; x = {2,3,4}
f(x) = 2x – 3; x = {5,6}
(i) f(5) + f(6)
f(x) = 2x – 3
f(5) = 2(5) – 3 = 10 – 3 = 7
f(6) = 2(6) – 3 = 12 – 3 = 9
∴ f(5) + f(6) = 7 + 9 = 16

(ii) f(1) – f(-3)
f(x) = 4x2 – 1
f(1) = 4(1)2 – 1 = 4 – 1 = 3
f(-3) = [4(-3)2 – 1]
= 4 (9) – 1
= 36 – 1 = 35
∴ f(1) – f(-3) = 3 – (35) = -32

(iii) f(-2) – f(4)
f(x) = 4x2 – 1
f(-2) = 4(-2)2 – 1 = 4(4) – 1 = 16 – 1 = 15
f(x) = 3x – 2
f(4) = [3(4) – 2] = 12 – 2 = 10
∴ f(-2) – f(4) = 15 – 10 = 5

Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions 30

Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions

Question 7.
A function f : [- 7, 6) → R is defined as follows
Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions 31
Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions 32
Answer:
Given, f(x) = x2 + 2x + 1 ; x = {-7, -6}
f(x) = x + 5 ; x = {-5, -4, -3, -2, -1, 0, 1, 2}
f(x) = x – 1; x{3, 4, 5}

(i) 2f(- 4) + 3f(2)
f(x) = x + 5
f(-4) = -4 + 5 = 1
f(2) = 2 + 5 = 7
∴ 2f(-4) + 3 f(2) = 2(1) + 3(7) = 2 + 21 = 23

(ii) f(-7) – f(-3)
f(x) = x2 + 2x + 1
f(-7) = (-7)2 + 2(-7) + 1 = 49 – 14 + 1 = 36
f(x) = x + 5
f(-3) = -3 + 5 = 2
∴ f(-7) – f(-3) = 36 – 2 = 34

(iii) \(\frac{4 f(-3)+2 f(4)}{f(-6)-3 f(1)}\)
f(x) = x + 5
f(-3) = -3 + 5 = 2
f(x) = x – 1
f(4) = 4 – 1 = 3
f(x) = x2 + 2x + 1
f(-6) = (-6)2 + 2(-6) + 1 = 36 – 12 + 1 = 25
f(x) = x + 5
f(1) = 1 + 5 = 6
Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions 33

Question 8.
Let A= { 0,1, 2, 3 } and B = {1, 3, 5, 7, 9 } be two sets. Let f: A → B be a function given by f (x) = 2x + 1. Represent this function as
(i) a set of ordered pairs
(ii) a table
(iii) an arrow diagram and
(iv) a graph.
Answer:
A = {0, 1, 2, 3}, B = { 1, 3, 5, 7, 9 },f(x) = 2x + 1
f(0) = 2(0) + 1 = 1, f(1) = 2(1) + 1 = 3 ,f(2) = 2(2) + 1 = 5, f(3) = 2(3) + 1 = 7

(i) Set of ordered pairs
The given function/can be represented as a set of ordered pairs as
f = {(0, 1), (1, 3), (2, 5), (3,7)}

(ii) Table form
Let us represent f using a table as shown below.
Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions 34

(iii) Arrow Diagram
Let us represent f by an arrow diagram.
We draw two closed curves to represent the sets A and B. Here each element of A and its unique image element in B are related with an arrow.
Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions 35

Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions

(iv) Graph
We are given that
f = {(x,f(x)) | x ∈ A} = {(0,1), (1, 3), (2, 5), (3, 7)}. Now, the points (0, 1), (1, 3), (2, 5) and (3, 7) are plotted on the plane as shown below.
The totality of all points represent the graph of the function.
Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions 36

Question 9.
A. function f: [1, 6) → R is defined as follows
Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions 37
(Here, [1, 6) = {x ∈ R : 1 ≤ x < 6})
Find the value of
(i) f(5)
(ii) f(3)
(iii) f(1)
(iv) f(2) – f(4)
(v) 2f(5) – 3f(1).
Answer:
(i) Let us find f(5). Since 5 lies between 4 and 6, we have to use f(x) = 3x2 – 10.
Thus, f(5) = 3(52) – 10 = 65.

(ii) To find f(3), note that 3 lies between 2 and 4.
So, we use f(x) = 2x – 1 to calculate f(3).
Thus, f(3) = 2(3) – 1 = 5.

(iii) Let us find f(1).
Now, 1 is in the interval 1 < x < 2
Thus, we have to use f(x) = 1 + x to obtain f(1) = 1 + 1 = 2.

(iv) f (2) – f(4)
Now, 2 is in the interval 2 < x < 4 and so, we use f(x) = 2x – 1.
Thus, f(2) = 2(2) -1 = 3.
Also, 4 is in the interval 4 < x < 6. Thus, we use f(x) = 3x2 – 10
Therefore, f(4) = 3(42) – 10 = 3(16) – 10 = 48 – 10 = 38.
Hence, f(2) – f(4) = 3 – 38 = -35.

(v) To calculate 2 f (5) – 3f (1), we shall make use of the values that we have already calculated in (i) and (iii). Thus, 2f(5) – 3f(1) = 2(65) – 3(2) = 130 – 6 – 124.

Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions

Question 10.
Given f(x) = 5x + 2; g(x) = 2x – 3;
h(x) = 3x + 1. Verify fo (goh) = (fog) oh
Answer:
f(x) = 5x + 2 ; g(x) = 2x – 3; h(x) = 3x + 1
L.H.S. = fo (goh)
goh = g[h(x)]
= g(3x + 1)
= 2(3x + 1) – 3
= 6x – 1
fo (goh) = f[goh (x)]
= f(6x – 1)
= 5 (6x – 1) + 2
= 30 x – 5 + 2
fo (goh) = 30x – 3 ….(1)
R.H.S. = (fog) oh
fog = f[g(x)]
= f(2x – 3)
= 5(2x – 3) + 2
= 30x – 5 + 2
fo (goh) = 30x – 3 …..(1)
R.H.S. = (fog) oh
fog = f[g(x)]
= f(2x – 3)
= 5 (2x – 3)
= 5 (2x – 3) + 2
= 10x – 15 + 2
= 10x – 13
(fog) oh = fog [h(x)]
= fog (3x + 1)
= 10 (3x + 1) – 13
= 30x + 10 – 13
= 30x – 3 ….(2)
From (1) and (2) we get L.H.S. = R.H.S.
fo(goh) = (fog) oh

Question 11.
Given f(x) = x2 + 4; g(x) = 3x – 2;
h(x) = x – 5. Show that the composition of functions is associative.
Answer:
f(x) = x2 + 4 ; g(x) – 3x – 2; h(x) = x – 5
To prove fo (goh) = (fog) oh
L.H.S. fo (goh)
goh = g[h(x)]
= g(x – 5)
= 3(x – 5) – 2
= 3x – 15 – 2
goh = 3x – 17
fo (goh) = f [goh (x)]
= f(3x – 17)
= (3x – 17)2 + 4
= 9x2 + 289 – 102 x + 4
= 9x2 – 102x + 293 ….(1)
R.H.S. = (fog) oh
fog – f[g(x)]
= f(3x-2)
= (3x – 2)2 + 4
= 9×2 + 4 – 12x + 4
= 9×2 – 12x + 8
(fog) oh = fog [h(x)]
= fog (x – 5)
= 9(x – 5)2 – 12 (x – 5) + 8
= 9(x2 + 25 – 10x) – 12x + 60 + 8
= 9x2 + 225 – 90x – 12x + 60 + 8
= 9x2 – 102x + 293 ….(2)
From (1) and (2) we get fo (goh) = (fog) oh.
Composition of function is associative

Samacheer Kalvi 10th Maths Guide Chapter 1 Relations and Functions Additional Questions

Question 12.
Given f(x) = x – 2; g(x) = 3x + 5; h(x) = 2x – 3. Verify that (goh) of = go (hof)
Answer:
f(x) = x – 2 ; g(x) = 3x + 5; h(x) = 2x – 3
L.H.S. (goh) of
goh = g[h(x)]
= g(2x – 3)
= 3(2x – 3) + 5
= 6x – 9 + 5
= 6x – 4
(goh) of = goh [f(x)]
= goh (x – 2)
= 6(x – 2) – 4
= 6x – 12 – 4
= 6x – 16 ….(1)

R.H.S. go(hof)
hof = h[f(x)]
= h(x- 2)
= 2(x – 2) – 3
= 2x – 4 – 3
= 2x – 7
go(hof) = g [hof (x)]
= g (2x – 7)
= 3(2x – 7) + 5
= 6x – 21 + 5
= 6x – 16 ….(2)
From (1) and (2) we get (goh) of = go(hof)

Samacheer Kalvi 9th Maths Guide Chapter 1 Set Language Ex 1.2

Students can download Maths Chapter 1 Set Language Ex 1.2 Questions and Answers, Notes, Samacheer Kalvi 9th Maths Guide Pdf helps you to revise the complete Tamilnadu State Board New Syllabus, helps students complete homework assignments and to score high marks in board exams.

Tamilnadu Samacheer Kalvi 9th Maths Solutions Chapter 1 Set Language Ex 1.2

Question 1.
Find the cardinal number of the following sets.
(i) M = {p, q, r, s, t, u}
(ii) P = {x : x = 3n + 2, n ∈ W and x < 15}
(iii) Q = {y : y = \(\frac{4}{3n}\), n ∈ N and 2 < n ≤ 5}
(iv) R = {x : x is an integer, x ∈ Z and – 5 ≤ x < 5}
(v) S = The set of all leap years between 1882 and 1906.
Solution:
(i) n (M) = 6
(ii) n (P) = 5 [n = {0, 1, 2, 3 . . . . 14}]
(iii) Since n = {3, 4, 5} ; n (Q) = 3
(iv) X = {-5, -4, -3, -2, -1, 0, 1, 2, 3, 4} ∴ n (R) = 10
(v) S = {1884, 1888, 1892, 1896, 1904}; n (S) = 5

Samacheer Kalvi 9th Maths Guide Chapter 1 Set Language Ex 1.2

Question 2.
Identify the following sets as finite or infinite.
(i) X = The set of all districts in Tamilnadu.
(ii) Y = The set of all straight lines passing through a point.
(iii) A = {x : x ∈ Z and x < 5}
(iv) B = {x : x² – 5x + 6 = 0, x ∈ N}
Solution:
(i) Finite
(ii) Infinite set (many lines can be drawn from a point)
(iii) Infinite set {A = ……. -2, -1, 0, 1, 2, 3, 4}
(iv) Finite set [x² – 5x + 6 = 0 ⇒ (x – 3) (x – 2) = 0; x = 3 and 2]

Question 3.
Which of the following sets are equivalent or unequal or equal sets?
(i) A = The set of vowels in the English alphabets.
B = The set of all letters in the word “VOWEL”
(ii) C = {2, 3, 4, 5}
D = {x : x ∈ W, 1 < x < 5}
(iii) X = {x : x is a letter in the word “LIFE”}
Y = {F, I, L, E}
(iv) G = {x : x is a prime number and 3 < x < 23}
H = {x : x is a divisor of 18}
Solution:
(i) Equivalent set [n(A) = n(B) = 5] ∴ A ≈ B
(ii) Unequal sets [C = {2, 3, 4, 5}; D = {2, 3, 4}]
(iii) Equal sets [X = {L, I, F, E}; Y = {F, I, L, E} [n(X) = 4 = n(Y)] ∴ X ≈ Y
(iv) Equivalent sets [G = {5, 7, 11, 13, 17, 19}; H = {1, 2, 3, 6, 9, 18}]
[n(G) = n(H) = 6 ∴ G ≈ H)]

Samacheer Kalvi 9th Maths Guide Chapter 1 Set Language Ex 1.2

Question 4.
Identify the following sets as null set or singleton set.
(i) A = {x : x ∈ N, 1 < x < 2}
(ii) B = The set of all even natural numbers which are not divisible by 2
(iii) C = {0}.
(iv) D = The set of all triangles having four sides.
Solution:
(i) Null set [No natural numbers is in between 1 and 2]
(ii) Null set [All the even natural numbers are not divisible by 2]
(Hi) Singleton set [n (C) = 1]
(iv) Null set [All the triangles has 3 sides]

Question 5.
State which pairs of sets are disjoint or overlapping?
(i) A = {f, i, a, s} and B = {a, n, f, h, s}
A = {f, i, a, s} and B = {a, n, f, h, s}
A and B are overlapping sets

(ii) C = {x : x is a prime number, x > 2} and D = {x : x is an even prime number}
C= {3, 5, 7…….}
D = {2}
C and D are disjoint sets

(iii) E = {x : x is a factor of 24} and F = {x : x is a multiple of 3, x < 30}
E = {1, 2, 3, 4, 6, 8, 12, 24}
F = {3, 6, 9, 12, 15, 18, 21, 24, 27} [Hint: E ∩ F = {3, 6, 24, …….}]
E and F are overlapping sets

Samacheer Kalvi 9th Maths Guide Chapter 1 Set Language Ex 1.2

Question 6.
If S = {square, rectangle, circle, rhombus, triangle}. List the elements of the following subset of S.
(i) The set of shapes which have 4 equal sides.
(ii) The set of shapes which have radius.
(iii) The set of shapes in which the sum of all interior angles is 180°.
(iv) The set of shapes which have 5 sides.
Solution:
(i) Subset of S = {square, rhombus}
(ii) Subset of S = {circle}
(iii) Subset of S = {triangle}
(iv) Subset of S = { }

Question 7.
If A = {a,{a, b}}, write all the subsets of A.
Solution:
A = {a, {a, b}}
Subset of A are Ø, {a}, {a, b}, {a, {a, b}} (or) { }, {a}, {a,b, {a,{a,b}}
P(A) = {Ø, {a}, {a, b}, {a {a, b}} (or) {{ }, {a}, {a,b, {a,{a,b}}

Samacheer Kalvi 9th Maths Guide Chapter 1 Set Language Ex 1.2

Question 8.
Write down the power set of the following sets.
(i) A = {a, b}
(ii) B = {1, 2, 3}
(iii) D = {p, q, r, s}
(iv) E = Ø
Solution:
(i) A = {a, b)
P(A) = {{},{a},{b}, {a, b}}

(ii) B = {1, 2, 3}
P(B) = {{}, {1}, {2}, {3}, {1,2}, {2, 3}, {1,3}, {1,2,3}}

(iii) D = {p, q, r, s}
P(D) = {{},{p},{q},{r},{s},{p, q} {p, r} {p, s}
{q, r}, {q, s}, {r, s}, {p, q, r} {q, r, s}
{p, r, s} {p, q, s} {p, q, r, s}}

(iv) E = Ø
P(E) = {{}}
Note: (empty set is the subset of all the sets)

Samacheer Kalvi 9th Maths Guide Chapter 1 Set Language Ex 1.2

Question 9.
Find the number of subsets and the number of proper subsets of the following sets.
(i) W = {red, blue, yellow}
(ii) X = {x² : x ∈ N, x² ≤ 100}
Solution:
(i) W = {red, blue, yellow}
n (W) = 3
The number of subsets of W = n [P(W)] = 2m
= 23 = 8
Number of proper subsets of W = n[P(W)] – 1
= 8 – 1
= 7 (or)
Number of proper subsets of W = 2m – 1
= 23 – 1 = 8 – 1 = 7

(ii) X = {x2 : x ∈ N, x2 ≤ 100}.
X= {1,2, 3, 4, …. 10}
n(X) = 10
The number of subsets of X = n[P(X)]
= 2m
= 210 = 1024
Number of proper subsets of X = 2m – 1
= 1024 – 1
= 1023

Samacheer Kalvi 9th Maths Guide Chapter 1 Set Language Ex 1.2

Question 10.
(i) If n(A) = 4, find n[P(A)]
(ii) If n(A) = 0, find n[P(A)]
(Hi) If n[P(A)] = 256, find n(A)
Solution:
(i) n (A) = 4
n [P(A)] = 2m = 24
= 16

(ii) n (A) = 0
n [P(A)] = 2m = 2° = 1

(iii) n [P(A)] = 256
Samacheer Kalvi 9th Maths Guide Chapter 1 Set Language Ex 1.2 1
2m = 28
∴ n (A) = 8

Samacheer Kalvi 9th Maths Guide Chapter 1 Set Language Ex 1.1

Students can download Maths Chapter 1 Set Language Ex 1.1 Questions and Answers, Notes, Samacheer Kalvi 9th Maths Guide Pdf helps you to revise the complete Tamilnadu State Board New Syllabus, helps students complete homework assignments and to score high marks in board exams.

Tamilnadu Samacheer Kalvi 9th Maths Solutions Chapter 1 Set Language Ex 1.1

Question 1.
Which of the following are sets?
(i) The collection of prime numbers upto 100
(ii) The collection of rich people in India
(iii) The collection of all rivers in India
(iv) The collection of good hockey players
Solution:
(i) It is a set
(ii) It is not a set (The word “rich” is not well defined)
(iii) It is a set
(iv) It is not a set (The word “good” is not well defined)

Samacheer Kalvi 9th Maths Guide Chapter 1 Set Language Ex 1.1

Question 2.
List the set of letters of the following words in Roster form.
(i) INDIA
(ii) PARALLELOGRAM
(iii) MISSISSIPPI
(iv) CZECHOSLOVAKIA
Solution:
(i) A = {I, N, D, A}
(ii) B = {P, A, R, L , E, O, G, M}
(iii) C = {M, I, S, P}
(iv) D = {C, Z, E, H, O, S, L, V, A, K, I}

Samacheer Kalvi 9th Maths Guide Chapter 1 Set Language Ex 1.1

Question 3.
Consider the following sets A = {0, 3, 5, 8}, B = {2, 4, 6, 10} and C = {12, 14, 18, 20}.
(a) State whether True or False:
(i) 18 ∈ C
(if) 6 ∉ A
(iii) 14 ∉ C
(iv) 10 ∈ B
(v) 5 ∈ B
(vi) 0 ∈ B
Solution:
(i) True
(ii) True
(iii) False
(iv) True
(v) False
(vi) False

(b) Fill in the blanks:
(i) 3 ∈ …………
(ii) 14 ∈…………
(iii) 18 ……….. B
(iv) 4 ………. B
Solution:
(i) A
(ii) C
(iii) ∉
(iv) ∈

Samacheer Kalvi 9th Maths Guide Chapter 1 Set Language Ex 1.1

Question 4.
Represent the following sets in Roster form.
(i) A = The set of all even natural numbers less than 20.
(ii) B = {y : y = \(\frac{1}{2n}\), n∈N, n ≤ 5}
(iii) C = {x : x is perfect cube, 27 < x < 216}
(iv) D = {x : x ∈Z, – 5 < x ≤ 2}
Solution:
(i) A= {2, 4, 6, 8, 10, 12, 14, 16, 18}
(ii) B = {\(\frac{1}{2}\), \(\frac{1}{4}\), \(\frac{1}{6}\), \(\frac{1}{8}\), \(\frac{1}{10}\)}
(iii) C = {64, 125}
(iv) D = {-4, -3, -2, -1, 0, 1, 2}

Samacheer Kalvi 9th Maths Guide Chapter 1 Set Language Ex 1.1

Question 5.
Represent the following sets in set builder form.
(i) B = The set of all cricket players in India who scored double centuries in one day internationals.
(ii) C = {\(\frac{1}{2}\), \(\frac{2}{3}\), \(\frac{3}{4}\), …….}
(iii) D = The set of all Tamil months in a year.
(iv) E = The set of odd Whole numbers less than 9.
Solution:
(i) B = {x : x is a set of all cricket players in India who scored double centuries in one day internationals}
(ii) C = {x : n ∈ N, x = \(\frac{n}{n + 1}\) }
(iii) D = {x : x ∈ set of all Tamil months in a year}
(iv) E = {x : x is an odd whole number and x < 9}

Samacheer Kalvi 9th Maths Guide Chapter 1 Set Language Ex 1.1

Question 6.
Represent the following sets in descriptive form.
(i) P = { January, June, July}
(ii) Q = {7, 11, 13, 17, 19, 23, 29}
(iii) R = {x : x∈N, x < 5}
(iv) S = {x : x is a consonant in English alphabets}
Solution:
(i) P = The set of all months beginning with the letter “J”
(ii) Q = The set of all prime numbers between 5 and 31
(iii) R = The set of natural numbers less than 5
(iv) S = The set of consonants in English alphabets

Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger

Tamilnadu State Board New Syllabus Samacheer Kalvi 11th Accountancy Guide Pdf Chapter 4 Ledger Text Book Back Questions and Answers, Notes.

Tamilnadu Samacheer Kalvi 11th Accountancy Solutions Chapter 4 Ledger

11th Accountancy Guide Ledger Text Book Back Questions and Answers

I. Choose the correct answer.

Question 1.
Main objective of preparing ledger account is to ………………..
(a) Ascertain the financial position
(b) Ascertain the profit or loss
(c) Ascertain the profit or loss and the financial position
(d) Know the balance of each ledger account
Answer:
(d) Know the balance of each ledger account

Question 2.
The process of transferring the debit and credit items from journal to ledger accounts is called ………….
(a) Casting
(b) Posting
(c) Journalising
(d) Balancing
Answer:
(b) Posting

Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger

Question 3.
J.F means
(a) Ledger page number
(b) Journal page number
(c) Voucher number
(d) Order number
Answer:
(b) Journal page number

Question 4.
The process of finding the net amount from the totals of debit and credit columns in a ledger is known as ……………
(a) Casting
(b) Posting
(c) Journalising
(d) Balancing
Answer:
(d) Balancing

Question 5.
If the total of the debit side of an account exceeds the total of its credit side, it means
(a) Credit balance
(b) Debit balance
(c) Nil balance
(d) Debit and credit balance
Answer:
(b) Debit balance

Question 6.
The amount brought into the business by the proprietor should be credited to
(a) Cash account
(b) Drawings account
(c) Capital account
(d) Suspense account
Answer:
(c) Capital account

II. Very Short Answer Type Questions

Question 1.
What is a ledger?
Answer:
Ledger account is a summary statement of all the transactions relating to a person, asset, liability, expense or income which has taken place during a given period of time and it shows their net effect From the transactions recorded in the journal, the ledger account is prepared. Ledger is known as principal book of accounts. It is a book which contains all sets of accounts, namely, personal, real and nominal accounts. Account wise balance can be determined from the ledger. The ledger accounts are prepared based on journal entries passed.

Question 2.
What is meant by posting?
Answer:
The process of transferring the debit and credit items from the journal to the ledger accounts is called posting.

Question 3.
What is debit balance?
Answer:
If the total on the debit side of an account is higher, the balancing figure is debit balance.

Question 4.
What is credit balance?
Answer:
If the credit side of an account has higher total, the balancing figure is credit balance.

Question 5.
What is balancing of an account?
Answer:
Balancing means that the debit side and credit side amounts are totalled and the difference between the total of the two sides is placed in the amount column as ‘Balance c/d’ on the side having lesser total, so that the total of both debit and credit columns are equal.

When the total of the debit side is more than the total of credit side the difference is debit balance and is placed on the credit side as ‘By Balance c/d’. If the credit side total is more than the total of debit side, the difference is credit balance and is placed on the debit side as ‘To Balance c/d’.

III. Short Answer Questions

Question 1.
Distinguish between journal and ledger.
Answer:
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 1a

Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger

Question 2.
What is ledger? Explain its utilities.
Answer:
1. Ledger account is a summary statement of all the transactions relating to a person, asset, liability, expense or income which has taken place during a given period of time and it shows their net effect.
2. It is a book which contains all sets of accounts, namely, personal, real and nominal accounts.
3. Account wise balance can be determined from the ledger.
4. The ledger accounts are prepared based on journal entries passed.

Quick information about a particular account:
Ledger account helps to get all information about a particular account like sales, purchases, machinery, etc., at a glance.

For example, where there are several transactions with a debtor, the net amount due from a debtor can be known from the ledger account.

Control over business transactions:
From the ledger balances extracted, a thorough analysis of account balances can be made which helps to have control over the business transactions.

Trial balance can be prepared:
With the balances of ledger accounts, trial balance can be prepared to check the arithmetical accuracy of entries made in the journal and ledger.

Helps to prepare financial statements:
From the ledger balances extracted, financial statements can be prepared for ascertaining net profit or loss and the financial position.

Question 3.
How is posting made from, the journal to the ledger?
Answer:
The process of transferring the debit and credit items from the journal to the ledger accounts is called posting. The procedure of posting from journal to ledger is as follows:
1. Locate the ledger account that is debited in the journal entry. Open the respective account in the ledger, if already not opened. Write the name of the account in the top middle. If already opened, locate the account from the ledger index. Now entries are to be made on the debit side of the account.

2. Record the date of the transaction in the date column on the debit side of that account.

3. Record the name of the account credited in the journal with the prefix ‘To’ in particulars column.

4. Record the amount of the debit in the ‘amount column’.

5. Locate the ledger account that is credited in the journal entry. Open the respective account in the ledger, if already not opened. Write the name of the account in the top middle. If already opened, locate the account from the ledger index. Now entries are to be made on the credit side of the account. Record the date of the transaction in the date column. Record the name of the account debited in the journal entry in the particulars column with the prefix ‘By’ and write the amount in the amount column.

Question 4.
Explain the procedure for balancing a ledger account.
Answer:
1. The debit and credit columns of an account are to be totalled separately.

2. The difference between the two totals is to be ascertained.

3. The difference is to be placed in the amount column of the side having lesser total. ‘Balance c/d’ is to be entered in the particulars column against the difference and in the date column the last day of the accounting period is entered.

4. Now both the debit and credit columns are to be totalled and the totals will be equal. The totals of both sides are to be recorded in the same line horizontally. The total is to be distinguished from other figures by drawing lines above and below the amount.

5. The difference has to be brought down to the opposite side below the total. ‘Balance b/d’ is to be entered in the particulars column against the difference brought down and in the date column, the first day of the next accounting period is entered.

6. If the total on the debit side of an account is higher, the balancing figure is debit balance and if the credit side of an account has higher total, the balancing figure is credit balance. If the two sides are equal, that account will show nil balance.

IV. Exercises

Question 1.
Journalise the following transactions and post them to ledger.
2016 Jan.1 Started business with cash – 10,000
5 Paid into bank – 5,000
7 Purchased goods from Ram for cash – 1,000
Answer:
Journal of Mr. X
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 1
Ledger Account
Cash Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 2
Bank Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 3

Question 2.
Give journal entries for the following transactions and post them to ledger.
2015, March 1 Goods sold to Somu on credit – 5,000
7 Furniture purchased for cash – 300
15 Interest received – 1,800
Answer:
Journal of Mr.Y
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 4
Ledger Account
Samu Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 5
Furniture Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 6

Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger

Question 3.
Pass journal entries for the following transactions and post them to ledger.
2017 Aug 1 Dharma started business with cash – 70,000
6 Cash received from Ganesan – 10,000
10 Rent paid – 3000
20 Received commission from Anand – 5000
Answer:
Journal of Mr. Dharma
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 7
Dharma Capital Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 8
Rent Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 9

Question 4.
Record the following transactions in the journal of Banu and post them to the ledger.
2018, Sep 1 Commenced business with cash – 90,000
5 Rent received – 4,000
12 Purchased 6 tables from Gobu & Co. for cash – 6,000
Answer:
Journal of Mr. Banu
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 10
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 11

Question 5.
The following balances appeared in the books of Vinoth on Jan 1, 2018.
Assets: Cash Rs 40,000; Stock Rs 50,000; Amount due from Ram Rs 20,000
Machinery Rs 40,000 Liabilities: Amount due to Vijay Rs 10,000
Pass the opening journal entry and post them to Vinoth’s Capital account,
Answer:
Opening Entry
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 12

Question 6.
Prepare Furniture A/c from the following transactions
2016, Jan 1 Furniture in hand – 2,000
1 Purchased furniture for cash – 4,000
30 Sold furniture – 400
Answer:
Furniture Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 13

Question 7.
The following balances appeared in the books of Kumaran on April 1, 2017.
Assets: Cash Rs 1,00,000; Stock Rs 40,000; Amount due from Rohit Rs 10,000;
Furniture Rs 10,000;
Liabilities: Amount due to Anusha Rs 40,000;
Kumaran’s capital Rs 1,20,000
Find the capital and show the ledger posting for the above opening balances.
Answer:
Opening Entry
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 14
Stock Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 15
Furniture Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 16
Kumaran Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 17

Question 8.
Give journal entries and post them to cash account.
2016, June 1 Commenced business with cash – 1,10,000
10 Introduced additional capital – 50,000
28 Withdrawn for personal use – 20,000
Answer:
Journal Entry
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 18

Question 9.
Give journal entries from the following transactions of Mohit, dealing in Textiles and post them to ledger.
2014 Aug 1 Commenced business with cash – 1,10,000
7 Opened bank account with SBI – 50,000
3 Purchased furniture for cash – 20,000
Answer:
Journal of Mohit
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 19
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 20
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 21

Question 10.
Give journal entries for the following transactions and post them to ledger.
2016, sep 1 Commenced business with cash – 80,000
7 Bought goods for cash from Roopan – 10,000
10 Purchased goods from Hema on credit – 42,000
22 Goods returned to Hema – 2,000
23 Cash paid to Hema – 10,000
Answer:
Journal of Entry Mr. Y
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 22
Ledger Account
Cash Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 23
Purchases Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 24

Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger

Question 11.
Give Journal entries for the following transactions and post them to Cash A/c and
Sales A/c.
2017, Aug 10 Sold goods and cheque received but not deposited – 30,000
14 Sold goods on credit to Gopi – 12,000
20 Received cash from Gopi – 12,000
Answer:
Journal of Entry Mr. Y
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 25
Cash Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 26

Question 12.
Journalise the transactions given below and post them to ledger.
2017 Oct. 18 Paid trade expenses – 1,000
25 Bought postage stamps – 100
30 Commission received – 6,000
30 Rent paid – 4,000
Answer:
Journal of Entries
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 27
Cash Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 28
Commission Received Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 29

Question 13.
Journalise the following transactions and prepare ledger accounts.
2015, Feb 1 Sold goods for cash – 5,000
2 Purchased goods from Kumar on credit – 4,000
5 Sold goods to Prabu on credit – 8,000
12 Received cash from Prabu – 1,200
20 Paid to Kumar – 2,000
25 Paid salary – 3,000
Answer:
Journal Entry
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 30
Sales Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 31
Prabhu Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 32
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 33

Question 14.
Enter the following transactions in the books of Ganesan and post them into ledger.
2017, Oct 1 Started business with cash – 25,000
5 Deposited into bank – 12,500
10 Purchased furniture and payment by cheque – 2,000
15 Goods purchased for cash – 5,000
19 Sold goods to Vasu on credit – 4,000
22 Goods worth Rs 500 taken for personal use
Answer:
Journal of Ganesan
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 34
Ledger Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 35
Bank Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 36
Vasu Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 37

Question 15.
Journalise the following transactions in the books of Arun and post them to ledger accounts
accounts.
2017, Dec 1 Arun started his business with cash – 10,000
3 Bought goods for cash – 1,500
8 Sold goods to Krishna on credit – 4,000
14 Purchased goods from Govind on credit – 2,000
25 Received cash from Krishna – 3,000
28 Cash paid to Govind – 1,000
Answer:
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 38
Ledger Account
Cash Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 39
Purchases Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 40
Sales Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 41

Question 16.
Journalise the following transactions and post them to ledger in the books of Raja.
2018, Mar 1 Sold goods to Senthil for cash – 9,000
5 Sold goods to Murali on credit – ,500
9 Cash sales – 6,000
18 Bought goods from Mani on credit – 3,200
23 Received Rs 4,000 from Murali in full settlement of his account
Answer:
Journal of Raja
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 42
Sales Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 43
Purchases Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 44

Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger

Question 17.
Journalise the following transactions and post them to the ledger.
2017, July 1 Cash in hand – 50,000
5 Goods purchased by cash – 30,000
7 Insurance paid – 2,500
10 Machinery purchased for cash – 9,000
15 Interest received – 2,000
18 Goods sold for cash – 7,000
Answer:
Journal of Entry of Mr. Y
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 45
Purchases Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 46
Machinary Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 47

Question 18.
Journalise the following transactions in the books of Vasu and post them to ledger accounts.
2017, Nov 1 Cash in hand Rs 1,00,000; Cash at bank: Rs 30,000
2 Vasu sold goods to Jothi for Rs 25,000 against a cheque and deposited the same in the bank
4 Received as commission Rs 5,000
8 Bank paid Rs 15,000 directly for insurance premium of Vasu.
15 Cash deposited into bank Rs 30,000
20 Cash withdrawn from bank for personal use Rs 45,000.
Answer:
Journal of Mr. Vasu
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 48
Ledger Account
Cash Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 49
Bank Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 50
Commission Received Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 51

Question 19.
Prepare Anand’s account from the following details.
2017, July 1 Credit balance of Anand’s A/c – 4,000
15 Amount paid to Anand – 2,000
18 Goods purchased from Anand on credit – 8,000
20 Paid to Anand – 3,960
Discount allowed by him – 40
25 Goods purchased from Anand – 5,000
Answer:
Ledger Account
Dr. Anand’s Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 52

Question 20.
Prepare a Sales account from the following transactions.
2018, Jan 1 Sold goods to Sam – 4,000
4 Sold goods to Suresh – 2,500
11 Sold goods to Joy – 8,000
17 Sold goods to Rajan – 3,000
Answer:
Ledger Account
Sales Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 53

Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger

Question 21.
Show the direct ledger postings for the following transactions:
2017, June 1 Raja commenced business with cash Rs 50,000,
6 Sold goods for cash Rs 8,000
8 Sold goods to Devi on credit Rs 9,000
15 Goods purchased for cash Rs 4,000
20 Goods purchased from Shanthi on credit Rs 5,000
Answer:
Ledger Account
Cash Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 54
Sales Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 55
Purchases Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 56

Question 22.
Show the direct ledger postings for the following transactions:
2017, July 1 Shankar commenced business with a cash of Rs 1,00,000
5 Sold goods for cash Rs 10,000
9 Wages paid Rs 6,000
19 Salaries paid Rs 8,000
20 Advertisement expenses paid Rs 4,000
Answer:
Ledger Account
Cash Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 57
Shankar Capital Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 58
wages Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 59

11th Accountancy Guide Ledger Additional Important Questions and Answers

I. Choose the correct answer.

Question 1.
Ledger is a book of:
(a) original entry
(b) final entry
(c) ail cash transactions
(d) contra entry
Answer:
(b) final entry

Question 2.
Personal and real accounts are:
(a) closed
(b) Balanced
(c) closed and transferred
(d) opening
Answer:
(b) Balanced

Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger

Question 3.
The column of ledger which links the entry with journal is
(a) L.F column
(b) J.F column
(c) Date column
(d) Particulars column
Answer:
(b) J.F column

Question 4.
Posting on the credit side of an account is written as
(a) To
(b) By
(c) Being
(d) Both (a) and (b)
Answer:
(b) By

Question 5.
Posting on the Debit side of an account is written as
(a) To
(b) By
(c) Being
(d) Both (a) and (b)
Answer:
(a) To

Question 6.
Nominal account having credit balance represents
(a) income / gain
(b) expenses / losses
(c) assets
(d) liabilities
Answer:
(a) income / gain

Question 7.
Nominal account having debit balance represents
(a) income / gain
(b) expenses / losses
(c) liability
(d) assets
Answer:
(b) expenses / losses

Question 8.
Real accounts always show
(a) debit balances
(b) credit balances
(c) nill balance
(d) Both (a) and (b)
Answer:
(a) debit balances

Question 9.
Account having credit balance is closed by writing
(a) To Balance b/d
(b) By Balance c/d
(c) To Balance c/d
(d) By Balance b/d
Answer:
(c) To Balance c/d

Question 10.
When the total of debits and credits are equal, it represents
(a) debit balance
(b) credit balance
(c) nil balance
(d) opening balance
Answer:
(c) nil balance

Question 11.
The balances of personal and real accounts are shown in the
(a) profit and loss account
(b) balance sheet
(c) trading account
(d) both (a) and (b)
Answer:
(b) balance sheet

Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger

Question 12.
If the total of the credit side of an account exceeds the total of its debit side, it means
(a) Credit balance
(b) Debit balance
(c) Nil balance
(d) Debit and credit balance
Answer:
(a) Credit balance

Question 13.
The closing balance is the next year’s
(a) debit balance
(b) credit balance
(c) nil balance
(d) opening balance
Answer:
(d) opening balance

Question 14.
The ledger account is prepared in format.
(a) T
(b) D
(c) C
(d) U
Answer:
(a) T

Question 15.
The process of recording business transactions in a chronological order is called ……………
(a) Recording
(b) Posting
(c) Journalizing
(d) Classifying
Answer:
(c) Journalizing

Question 16.
Which one of the following is known as the king of all books of accounts?
(a) Recording
(b) Posting
(c) Journalizing
(d) Classifying
Answer:
(c) Journalizing

Question 17.
A decrease in the provision for doubtful debts would result in
(a) Increase in liability
(b) Decrease in liability
(c) Decrease in the net profit
(d) Increase in the net profit
Answer:
(d) Increase in the net profit

Question 18.
The discount which is calculated on the list price of the goods is called .
(a) Cash discount
(b) Rebate
(c) Trade discount
(d) Discount
Answer:
(c) Trade discount

Question 19.
Merchandise stolen by someone should be debited to …………..
(a) Sales account
(b) Purchases account
(c) Loss by theft account
(d) None of the above
Answer:
(c) Loss by theft account

Question 20.
The owner of the business takes Rs.100 cash and goods costing Rs.200 for his family. The proper journal entry for this transaction is called ……………..
(a) drawing > debit; Cash > Credit; Purchases > Credit
(b) Drawing > debit; Cash > Credit; merchandise > credit
(c) Drawing > debit; Cash > credit; Sales > credit
(d) cash > debit; Purchases > debit; drawings > credit
Answer:
(a) drawing > debit; Cash > Credit; Purchases > Credit

II. Very Short Answer Type Questions

Question 1.
What is Nil balance?
Answer:
If the two sides are equal, that account will show nil balance.

Question 2.
What are the steps involved in posting the opening entry?
Answer:
Step 1:
The items debited in the opening entry are entered on the debit side of respective accounts. The words ‘To Balance b/d’ are written in the particulars column with respective amounts in the amount column, date being the first day of the accounting period.

Step 2:
The items credited in the opening entry are entered on the credit side of respective accounts. The words ‘By Balance b/d’ are written in the particulars column with respective amounts in the amount column, date being the first day of the accounting period.

Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger

Question 3.
Indicate the nature of normal balance in the following accounts.
Answer:
a. Cash – Debit balance
b. Creditors – Credit balance
c. Sales – Credit balance
d. Furniture – Debit balance
e. Commission received – Credit balance
f. Debtors – Debit balance
g. Purchases – Debit balance
h. Capital – Credit balance
i. Discount earned – Credit balance
j. Computer – Debit balance

Question 4.
Define ledger.
Answer:
According to L.C. Cropper, ‘the book which contains a classified and permanent record of all the transactions of a business is called the Ledger’.

Question 5.
What is compound journal entry?
Answer:
When a journal entry has more than one debit or more than one credit or both, it is called a compound entry.

III. Additional Sums

Question 1.
Prepare cash account A/c from the following transactions.
2018 Jan. 1 Commenced business with cash Rs 62,000
2 Good purchased for cash Rs 12,000
10 Cash sales Rs 10,000
12 Wages paid Rs 4,000
25 Furniture purchased for cash Rs 6,000
Answer:
Ledger Account
Cash Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 60

Question 2.
Prepare a sales A/c from the following transaction.
2018 Feb. 1 Cash sales – 5,000
4 Sold goods to Suresh – 4,000
8 Sold goods to Mohan – 8,000
12 Sold goods for cash – 3,000
Answer:
Ledger Account
Sales Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 61

Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger

Question 3.
Prepare Rangasamy A/c for the following transaction.
2017 Aug. 17 Goods purchased from Rangasamy Rs. 20,000
19 Goods returned to Rangasamy Rs. 5,000
31 Settles Rangasamy’s account
Answer:
Ledger Account
Rangasamy Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 62

Question 4.
Prepare Chitra account from the following transaction.
2018 March. 18 Sold goods to Chitra Rs. 1,26,000
24 Chitra returned goods Rs. 6,000
28 Chitra settled her account
Answer:
Chitra Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 63

Question 5.
Journalise the following transaction and post them to ledger in the book of Mr. Raja.
2018, Jan. 1 Started business with cash Rs 3,00,00
2 Opening bank account by deposition Rs 2,00,000
5 Purchased goods for cash Rs 10,000
15 Cash sales Rs 5,000
22 Purchased goods from X and Co. for Rs 15,000 and the payment is made through net banking
25 Sold goods for Y and Co. for Rs 30,000 and the payment is received thought NEET
Answer:
Journal of Mr. Raja
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 64
Ledger Account
Cash Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 65
Raja Capital Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 66
Purchases Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 67

Question 6.
Post the following Journal into Ledger of Thiru. Gowri Shankar.
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 68
Answer:
Ledger Account
Cash Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 69
Sayeed Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 70
David Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 71

Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger

Question 7.
Show the sivect ledger positions for the following transaction.
2018, May. 1 Commenced business with cash Rs 1,50,000
2 Sold goods for cash Rs 50,000
5 Purchases goods for cash Rs 25,000
25 Salaries paid Rs 15,000
30 Wages paid Rs 10,000
Answer:
Ledger Account
Cash Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 72
Capital Account
Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger 73

Samacheer Kalvi 11th Accountancy Guide Chapter 4 Ledger

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Tamilnadu State Board New Syllabus Samacheer Kalvi 11th Computer Science Guide Pdf Chapter 14 Classes and Objects Text Book Back Questions and Answers, Notes.

Tamilnadu Samacheer Kalvi 11th Computer Science Solutions Chapter 14 Classes and Objects

11th Computer Science Guide Classes and Objects Text Book Questions and Answers

Book Evaluation

Part I

Choose The Correct Answer
Question 1.
The variables declared inside the class are known as data members and the functions are known as
a) data functions
b) inline functions
c) member functions
d) attributes
Answer:
c) member functions

Question 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
Answer:
b) i-False, ii-True

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 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
Answer:
c) nesting of member function

Question 4.
The member function defined within the class behave like
a) inline functions
b) Non inline function
c) Outline function
d) Data function
Answer:
a) inline functions

Question 5.
Which of the following access specifier protects data from inadvertent modifications?
a) Private
b) Protected
c) Public
d) Global
Answer:
a) Private

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 6.
class x
{
inty;
public:
x(int z)
{
y=z;
}
} x1[4];
intmain( )
{
x x2(10);
return 0;
}
How many objects are created for the above program?
a) 10
b) 14
c) 5
d) 2
Answer:
c) 5

Question 7.
State whether the following statements about the constructor are True or False.
i) constructors should be declared in the private section.
ii) constructors are invoked automatically when the objects are created.
a) True, True
b) True, False
c) False, True
d) False, False
Answer:
c) False, True

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 8.
Which of the following constructor is executed for the following prototype ?
add display (add &); // add is a class name
a) Default constructor
b) Parameterized constructor
c) Copy constructor
d) Non Parameterized constructor
Answer:
c) Copy constructor

Question 9.
What happens when a class with parameterized constructors and having no default constructor is used in a program and we create an object that needs a zero- argument constructor?
a) Compile-time error
b) Domain error
c) Runtime error
d) Runtime exception
Answer:
a) Compile-time error

Question 10.
Which of the following create a temporary instance?
a) Implicit call to the constructor
b) Explicit call to the constructor
c) Implicit call to the destructor
d) Explicit call to the destructor
Answer:
b) Explicit call to the constructor

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Part – II

Very Short Answers

Question 1.
What are called members?
Answer:
The class comprises members. Members are classified 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.

Question 2.
Differentiate structure and class though both are user-defined data types.
Answer:
The only difference between structure and class is the members of the structure are by default public whereas it is private in class.

Question 3.
What is the difference between the class and object in terms of oop?
Answer:
Object:

  • Object is an instance of a class.
  • Object is a real-world entity such as pen, laptop, mobile, chair, etc.
  • Object allocates memory when it is created.

Class:

  • Class is a blueprint or template from which objects are created.
  • Class is a group of similar objects.
  • Class doesn’t allocate memory when it is created.

Question 4.
Why it is considered a good practice to define a constructor though a compiler can automatically generate a constructor?
Answer:
A user-defined constructor is the best method of initialise array of objects and normal objects.

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 5.
Write down the importance of the destructor.
Answer:
The purpose of the destructor is to free the resources that the object may have acquired during its lifetime. A destructor function removes the memory of an object which was allocated by the constructor at the time of creating an object.

Part – III

Short Answers

Question 1.
Rewrite the following program after removing the syntax errors if any and underline the errors:
#include<iostream>
#include<stdio.h>
classmystud
{ intstudid =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( );
}
Answer:
MODIFIED PROGRAM:
#include<iostream>
#include<stdio.h>
class mystud
{
int studid;
char name[20];
public:
mystud( )
{
studid=1001;
}
void register ( )
{
cin>>stdid;
gets(name);
}
void display ( )
{
cout<<studid<<“: “<<name<<endl;
}
};
int main( )
{
mystud MS;
MS.reqister( );
MS.display( );
}

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 2.
Write with an example of how will you dynamically initialize objects?
Answer:
Dynamic initialization of Objects:
When the initial values are provided during runtime then it is called dynamic initialization.
Program to illustrate dynamic initialization
#include
using namespace std;
class X
{
int n;
float avg;
public:
X(int p,float q)
{
n=p;
avg=q;
}
void disp( )
{
cout<<“\n Roll numbe:-” <<n;
cout<<“\nAverage :-“<<avg;
}
};
int main( )
{
int a ; float b;
cout<<“\nEnter the Roll Number”;
cin>>a; .
cout<<“\nEnter the Average”;
cin>>b;
X x(a,b); // dynamic initialization
x.disp( );
return 0;
}
Output
Enter the Roll Number 1201
Enter the Average 98.6
Roll number:- 1201
Average :- 98.6

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 3.
What are advantages of declaring constructors and destructor under public access ability?
Answer:

When constructor and destructor are declared under public:

  1. we can initialize the object while declaring it.
  2. we can explicitly call the constructor.
  3. we can overload constructors and therefore use multiple constructors to initialize objects automatically.
  4. we can destroy the objects at the end of class scope automatically (free unused memory).

However, some C++ compiler and Dev C++ do not allow to declare constructor and destructor under private section. So it is better to declare constructor and destructor under public section only.

Question 4.
Given the following C++ code, answer the questions (i) & (ii).
Answer:
class TestMeOut
{
public:
~TestMeOut( ) //Function 1
{
cout<<“Leaving the examination hall”<<endl;
}
TestMeOut( ) //Function 2
{
cout<<“Appearing for examination'<<endl;
}
void MyWork( ) //Function 3
{
cout<<“Attempting Questions//<<endl;
}
};
i) In Object-Oriented Programming, what is Function 1 referred to as and when does it get invoked/called?
Function 1 is called a destructor. It will be automatically invoked when the object goes out of scope (ie. at the end of a program).

ii) In Object-Oriented Programming, what is Function 2 referred to as, and when does it get invoked/called?
Function2 is called a constructor. It will be automatically invoked when an object comes into scope.(ie. at the time of object creation).

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 5.
Write the output of the following C++ program code:
Answer:
#include<iostream>
using namespace std;
class Calci
{
char Grade; .
int Bonus;
public:
Calci( )
{
Grade=’E’;
Bonus=0;
}//ascii value of A=65
void Down(int G)
{
Grade-=G;
}
void Up(int G)
{
Grade+=G;
Bonus++;
}
void Show( )
{
cout<<Grade<<“#”<<Bonus<<endl;
}
};
int main( )
{
Calci c;
c.Down(3);
c.Show( );
c.Up(7);
c.Show( );
c.Down(2);
c.Show( );
return 0;
}
Output
Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects 1

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Part – IV

Explain In Detail

Question 1.
Explain nested class with example.
Answer:
When one class becomes a member of another class then it is called Nested class and the relationship is called containership. When a class is declared within another class, the inner class is called a Nested class (i.e. the inner class) and the outer class is known as the Enclosing class. The nested class can be defined in private as well as in the public section of the Enclosing class.

Classes can be nested in two ways:

  1. By defining a class within another class
  2. By declaring an object of a class as a member to another class
  3. By defining a class within another class

C++ program to illustrate the nested class
#include<iostream>
using namespace std;
class enclose
{
private:
int x;
class nest
{
private :
int y;
public:
int z;
void prn( )
{
y=3;z=2;
cout<<“\n The product of”
< <y< <‘*'< <z<<“= “< <y*z< <“\n”;
}
}; //inner class definition over
nest m1;
public:
nest n2;
void square( )
{
n2.prn( ); //inner class member function is called by its object
x=2;
n2.z=4;
cout<<“\n The product of” <<n2.z<<‘*'<<n2.z<<“=”n2.z*n2.z<<“/n”;
cout<<“\n The product of” <<x<<‘*'<<x<<“= “<<x*x;
}
}; //outer class definition over
int main( )
{
enclose e;
e.square( ); //outer class member function is called
}
Output
The product of 3*2=6
The product of 4*4=16
The product of 2*2=4

In the above program the inner class nest is defined inside the outer class enclose, nest is accessed by enclose by creating an object of nest

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 2.
Mention the differences between constructor and destructor.
Answer:

CONSTRUCTOR

DESTRUCTOR

The name of the constructor must be same as that of the class.The destructor has the same name as that of the class prefixed by the tilde character
A constructor can have parameter list.The destructor cannot have arguments.
The constructor function can be overloaded.Destructors cannot be overloaded i.e., there can be only one destructor in a class.
Constructor cannot be inherited but a derived class can call the base class constructor.Destructor cannot be inherited.
The constructor is executed automatically when the object is created.The destructor is executed automatically when the control reaches the end of class.
Allocated memory space for the object.Destroy the object.

Question 3.
Define a class RESORT with the following description in C++ :
Answer:
Private members:
Rno // Data member to storeroom number
Name //Data member to store user name
Charges //Data member to store per day charge
Days //Data member to store the number of days
Compute ( ) // A function to calculate total amount as Days * Charges and if the
//total amount exceeds 11000 then total amount is 1.02 * Days *Charges

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
PROGRAM
using namespace std;
#include<iostream>
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<<“\nEnter customer name : “;
cin>>Rname;
cout<<‘nEnter charges per day : “;
cin>>Charges;
cout< <‘nEnter Number of days : “;
cin>>Days;
cout<<‘n Enter Room Number : “;
cin>>Rno;
}
dispinfo( )
{
cout<<‘nRoom Number :
“<<Rno;
cout<<‘nCustomer name :
“<<Rname;
cout<<‘nCharges per day :
“<<Charges;
cout<<‘nNumber of days :
“<<Days;
cout<<‘nTotal Amount :
“<<compute( );
}
int main( )
{
RESORT Obj;
Obj,getinfo( );
Obj.dispinfo( );
Output
Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects 2

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 4.
WrIte the output of the following:
Answer:
#include<iostream>
#indude<stdio.h>
using namespace std;
class sub
{
int day, subno;
public :
sub(int,int); // prototype
void printsub( )
{
cout<<” subject number: “<<subno;
cout<<” Days : ” <<day;
}
};
sub::sub(int d=150,int sn=12)
{
cout<<endl<<“Constructing the object
“<<endl;
day=d;
sub no=sn;
}
class stud ‘
{
int rno;
float marks; public:
stud( )
{
cout<< “Constructing the object of
students “<<endl;
rno=0;
marks=0.0;
}
void getval( )
{
cout<<“Enter the roll number and the marks secured”; cin>>rno>>marks;
}
void printdet( )
{
cout<<“Roll no : “<<rno<<“Marks : “<<marks<<endl; .
}
};
class admission
{
sub obj;
stud objone;
float fees; ,
public :
admission ( )
{
cout<< “Constructing the object of admission “<<endl;
fees=0.0;
}
void printdet( )
{
objone.printdet( );
obj.printsub();
cout<<“fees : “<<fees<<endl;
}
};
int main( )
{
system (“cls”);
admission adm;
cout<<endl<< ?’Back in main ()”;
return 0;
}
Output
Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects 3

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 5.
Write the output of the following.
Answer:
#indude<iostream>
#include<stdio,h>
using namespace std;
class P
{
public:
P( )
{
cout<< “\nConstructor of class P }
~P( )
{
cout< < “\nDestructor of class P
}
};
class Q
{
public:
Q( )
{
cout< <“\nConstructor of class Q “;}
~ Q( )
{
cout<< “\nDestructor of class Q
}
};
class R
{
P obj1, obj2;
Q obj3;
public:
R( )
{
cout<< “\nConstructor of class R “;}
~R( )
{
cout<< “\nDestructor of class R
}
};
int main ( )
{
R oR; :
Q oq;
Pop;
return 0;
Output
Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects 4

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

11th Computer Science Guide Classes and Objects Additional Questions and Answers

Choose The Correct Answer (1 Mark)

Question 1.
The most important feature of C++ is ………………..
(a) object
(b) class
(c) public
(d) All the above
Answer:
(b) class

Question 2.
How many features are commonly present in OOP languages?
a) 3
b) 2
c) 4
d) 5
Answer:
c) 4

Question 3.
Calling a member function of an object is also known as ……………….. to object.
(a) call function
(b) call by value
(c) call by reference
(d) sending message
Answer:
(d) sending message

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 4.
……………… is a way to bind the data and its associated functions together,
a) Class
b) Array
c) Structure
d) All the above
Answer:
a) Class

Question 5.
When one class become a member of another class, the relationship is called ………………..
(a) containership
(b) partnership
(c) friendship
(d) all the above
Answer:
(a) containership

Question 6.
The body of the class is defined inside the ………………. brackets.
a) Angle < >
b) Square [ ]
c) Curly { }
d) None of these
Answer:
c) Curly { }

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 7.
……………….. can be defined either in private or in the public section of a class.
(a) Object
(b) Data type
(c) Memory
(d) constructor
Answer:
(d) constructor

Question 8.
The members of the structure are by default ………………..
a) Private
b) Public
c) Protected
d) None of these
Answer:
b) Public

Question 9.
There are ……………….. ways to create an object using the parameterized constructor.
(a) 3
(b) 2
(c) 1
(d) 4
Answer:
(c) 1

Question 10.
The class body contains ………………….
a) Data members
b) Member functions
c) Both A and B
d) None of these
Answer:
c) Both A and B

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 11.
The class body has………………… access specifiers.
a) Three
b) Four
c) Two
d) Five
Answer:
a) Three

Question 12.
The class body has…………….. access specifiers.
a) Private
b) Public
c) Protected
d) All the above
Answer:
d) All the above

Question 13.
…………………. is a visibility label.
a) Private
b) Public
c) Protected
d) All the above
Answer:
d) All the above

Question 14.
……………….. allows preventing the functions of a program to access directly the internal representation of a class type.
a) Data Hiding
b) Data Capturing
c) Data Processing
d) None of these
Answer:
a) Data Hiding

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 15.
The access restriction to the class members is specified by ……………. section within the class
body.
a) Private
b) Public
c) Protected
d) All the above
Answer:
d) All the above

Question 16.
A …………………. member is accessible from where outside the class but within a program.
a) Private
b) Public
c) Protected
d) All the above
Answer:
b) Public

Question 17.
We can set and get the value of public data members using ………………… function.
a) Member
b) Nonmember
c) Either A or B
d) None of these
Answer:
c) Either A or B

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 18.
A …………….. member cannot be accessed from outside the class.
a) Private
b) Public
c) Protected
d) All the above
Answer:
a) Private

Question 19.
Only the class member functions can access ……………… members.
a) Private
b) Public
c) Protected
d) All the above
Answer:
a) Private

Question 20.
……………….. members can be accessed in child classes.
a) Private
b) Public
c) Protected
d) All the above
Answer:
c) Protected

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 21.
If all members of the class are defined as …………….. then the class become frozen.
a) Private
b) Public
c) Protected
d) All the above
Answer:
a) Private

Question 22.
If all members of the class are defined as ………………….. then the object of the class can not access anything from the class,
a) Private
b) Public
c) Protected
d) All the above
Answer:
a) Private

Question 23.
………………. are the data variables that represent the features or properties of a class.
a) Data members
b) Member functions
c) Both A and B
d) None of these
Answer:
a) Data members

Question 24.
………………… are the functions that perform specific tasks in a class.
a) Data members
b) Member functions
c) Both A and B
d) None of these
Answer:
b) Member functions

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 25.
Member functions are called as …………………..
a) Methods
b) Attributes
c) Properties
d) None of these
Answer:
a) Methods

Question 26.
Data members are also called as ……………….
a) Methods
b) Attributes
c) Properties
d) None of these
Answer:
b) Attributes

Question 27.
Classes contain a special member function called as ……………………
a) Constructors
b) Destructors
c) Both A and B
d) None of these
Answer:
c) Both A and B

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 28.
The member functions of a class can be defined in ……………….. ways.
a) Two
b) Three
c) Four
d) Five
Answer:
a) Two

Question 29.
The member functions of a class can be defined in ………………. way.
a) Inside the class definition
b) Outside the class definition
c) Either A or B
d) None of these
Answer:
c) Either A or B

Question 30.
When a member function is defined Inside a class, it behaves like ………………. functions.
a) Inline
b) General
c) Local
d) None of these
Answer:
a) Inline

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 31.
If a function is inline, the compiler places a copy of the code of that function at each point where the function is called at ………………….
a) Run Time
b) Compile time
c) Both A and B
d) None of these
Answer:
b) Compile time

Question 32.
When Member function defined outside the class, and then it is be called as ………………….
member function.
a) Outline
b) Non-inline
c) Either A or B
d) None of these
Answer:
c) Either A or B

Question 33.
When Member function defined outside the class using …………….. operator.
a) Scope resolution
b) Membership
c) Reference
d) Conditional
Answer:
a) Scope resolution

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 34.
The class variables are called ………………….
a) Object
b) Attributes
c) Procedures
d) None of these
Answer:
a) Object

Question 35.
Objects are also called as …………………. of class.
a) Instant
b) Instance
c) Attributes
d) None of these
Answer:
b) Instance

Question 36.
Objects can be created in ………………… methods.
a) Three
b) Four
c) Two
d) Five
Answer:
c) Two

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 37.
Objects can be created as ……………….
a) Global object
b) Local object
c) Either A or B
d) None of these
Answer:
c) Either A or B

Question 38.
…………….. objects can be used by any function in the program.
a) Global object
b) Local object
c) Either A or B
d) None of these
Answer:
a) Global object

Question 39.
If an object is declared outside all the function bodies or by placing their names immediately after the closing brace of the class declaration then it is called as ……………….
a) Global object
b) Local object
c) Either A or B
d) None of these
Answer:
a) Global object

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 40.
If an object is declared within a function then it is called ……………….
a) Global object
b) Local object
c) Either A or B
d) None of these
Answer:
b) Local object

Question 41.
……………….. object can not be accessed from outside the function.
a) Global
b) Local
c) Either A or B
d) None of these
Answer:
b) Local

Question 42.
No separate space is allocated for …………………. when the objects are created.
a) Member functions
b) Data members
c) Both A and B
d) None of these
Answer:
a) Member functions

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 43.
Memory space required for the ……………….
a) Member functions
b) Data members
c) Both A and B
d) None of these
Answer:
b) Data members

Question 44.
The members of a class are referenced (accessed) by using the object of the class followed by the ………………. operator.
a) Scope resolution
b) Conditional
c) Dot (membership)
d) None of these
Answer:
c) Dot (membership)

Question 45.
Calling a member function of an object is also known as ……………….
a) Sending a message to object
b) Communication with the object
c) Either A or B
d) None of these
Answer:
c) Either A or B

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 46.
An array which contains the class type of element is called …………………
a) Array of objects
b) Structure Objects
c) Block of objects
d) None of these
Answer:
a) Array of objects

Question 47.
The ………………… of the outline member function given in a class specification, instructs the compiler about its visibility mode.
a) Name
b) Prototype
C) Data type
d) None of these
Answer:
b) Prototype

Question 48.
A member function can call another member function of the same class directly without using the dot operator is called ………………………
a) Nesting of the member function
b) Invariant Members
c) Variant Members
d) None of these
Answer:
a) Nesting of the member function

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 49.
A member function can call another member function of the same class for that you do not
need a(n) …………………..
a) Member function
b) Data Member
c) Object
d) None of these
Answer:
c) Object

Question 50.
A member function can access ………………. functions.
a) Public
b) Private
c) Both A and B
d) None of these
Answer:
c) Both A and B

Question 51.
…………………. operator will reveal the hidden file scope(global) variable.
a) Membership
b) Conditional
c) Scope resolution
d) All the above
Answer:
c) Scope resolution

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 52.
When an object is passed by ……………… the function creates its own copy of the object and works on it.
a) Value
b) Reference
c) Either A or B
d) None of these
Answer:
a) Value

Question 53.
When an object is passed by …………….. changes made to the object inside the function do not affect the original object.
a) Value
b) Reference
c) Either A or B
d) None of these
Answer:
a) Value

Question 54.
When an object is passed by ……………….. its memory address is passed to the function so the called function works directly on the original object used in the function call.
a) Value
b) Reference
c) Either A or B
d) None of these
Answer:
b) Reference

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 55.
When an object is passed by ………………………. any changes made to the object inside the function definition are reflected in the original object.
a) Value
b) Reference
c) Either A or B
d) None of these
Answer:
b) Reference

Question 56.
Member Functions can ………………….
a) Receive object as an argument
b) Return an object
c) Both A and B
d) None of these
Answer:
c) Both A and B

Question 57.
When one class become a member of another class then it is called ……………. class.
a) Nested
b) Inline
c) External
d) Global
Answer:
a) Nested

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 58.
When one class becomes a member of another class then the relationship is called ………………….
a) Containership
b) Nesting
c) Parent-Child
d) None of these
Answer:
a) Containership

Question 59.
Classes can be nested in ……………….. ways.
a) Three
b) Two
c) Four
d) Five
Answer:
b) Two
Question 60.
Classes can be nested in ………………..way.
a) By defining a class within another class
b) By declaring an object of a class as a member to another class
c) Either A or B
d) None of these
Answer:
c) Either A or B

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 61.
When a class is declared within another class, the inner class is called a Nested class (ie the inner class) and the outer class is known as …………………… class.
a) Enclosing
b) Abstract
c) Transit
d) None of these
Answer:
a) Enclosing

Question 62.
The nested class can be defined in ………………….. section of the Enclosing class.
a) Private
b) Public
c) Either Private or Public
d) None of these
Answer:
c) Either Private or Public

Question 63.
Whenever an object of a class is declared as a member of another class it is known as a _____ class.
a) Abstract
b) Container
c) Literal
d) None of these
Answer:
b) Container

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 64.
Instantiating object is done using ……………….
a) Constructor
b) Destructor
c) Data abstraction
d) Data hiding
Answer:
a) Constructor

Question 65.
A(n) ………………..in C++ can be initialized during the time of their declaration.
a) Array
b) Structure
c) Array or Structure
d) None of these
Answer:
c) Array or Structure

Question 66.
Member function of a class can access all the members irrespective of their associated …………………..
a) Access specifier
b) Data type
c) Return type
d) Argument
Answer:
a) Access specifier

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 67.
When an instance of a class comes into scope, a special function called the ……………. gets executed.
a) Constructor
b) Destructor
c) Data abstraction
d) Data hiding
Answer:
a) Constructor

Question 68.
The constructor function name has the same name as the …………….. name.
a) Object
b) Class
c) Data member
d) None of these
Answer:
b) Class

Question 69.
The constructors return ………………
a) int
b) char
c) float
d) nothing
Answer:
d) nothing

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 70.
…………………. are not associated with any data type
a) Constructor
b) Data member
c) Data abstraction
d) Member functions
Answer:
a) Constructor

Question 71.
……………… can be defined either inside class definition or outside the Class definition.
a) Constructor
b) Destructor
c) Data abstraction
d) Member functions
Answer:
a) Constructor

Question 72.
A constructor can be defined in ……………… section of a class.
a) Private
b) Public
c) Either Private or Public
d) None of these
Answer:
c) Either Private or Public

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 73.
If a constructor is defined in ………………… section of a class, then only its object Can be created in any function.
a) Private
b) Public
c) Either Private or Public
d) None of these
Answer:
b) Public

Question 74.
The main function of the constructor is ……………………….
a) To allocate memory space to the object
b) To initialize the data member of the class object
c) Either A or B
d) None of these
Answer:
c) Either A or B

Question 75.
A constructor that accepts no parameter is called …………………… constructor.
a) Null
b) Default
c) Empty
d) None of these
Answer:
b) Default

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 76.
Identify the correct statement from following with respect to constructor.
a) If a class does not contain an explicit constructor (user defined constructor) the compiler automatically generate a default constructor implicitly as an inline public member.
b) In the absence of user defined constructor the compiler automatically provides the default constructor. It simply allocates memory for the object.
c) Parameterized constructor is achieved by passing parameters to the function.
d) All the above
Answer:
d) All the above

Question 77.
A constructor which can take arguments is called ……………….. constructor.
a) Parmeterized
b) Default
c) Empty
d) None of these
Answer:
a) Parmeterized

Question 78.
……………….. type of constructor helps to create objects with different initial values.
a) Parmeterized
b) Default
c) Empty
d) None of these
Answer:
a) Parmeterized

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 79.
Declaring a constructor with arguments hides the ……………………
a) Data members
b) Compiler generated constructor
c) Member functions
d) None of these
Answer:
b) Compiler generated constructor

Question 80.
………………… Constructor is used to creating an array of objects.
a) Default
b) Parameterized
b) Overloaded
d) None of these
Answer:
a) Default

Question 81.
There are ………………. ways to create an object using the parameterized constructor.
a) Three
b) Two
c) Four
d) Five
Answer:
b) Two

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 82.
……………… is a way to create an object using the parameterized constructor,
a) Implicit call
b) Explicit call
c) Either A or B
d) None of these
Answer:
c) Either A or B

Question 83.
In …………….. method, the parameterized constructor is invoked automatically
whenever an object is created.
a) Implicit call
b) Explicit call
c) Either A or B
d) None of these
Answer:
a) Implicit call

Question 84.
In the………………….. method, the name of the constructor is explicitly given to invoking the parameterized constructor.
a) Implicit call
b) Explicit call
c) Either A or B
d) None of these
Answer:
b) Explicit call

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 85.
………………… method is the most suitable method as it creates a temporary object
a) Implicit call
b) Explicit call
c) Either A or B
d) None of these
Answer:
b) Explicit call

Question 86.
The chance of data loss will not arise in ………………….. method.
a) Implicit call
b) Explicit call
c) Either A or B
d) None of these
Answer:
b) Explicit call

Question 87.
A ……………….. object lives in memory as long as it is being used in an expression.
a) Temporary
b) Nested
c) Inline
d) None of these
Answer:
a) Temporary

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 88.
A constructor having a reference to an already existing object of its own class is called ………………….. constructor.
a) Reference
b) Value
c) Copy
d) Move
Answer:
c) Copy

Question 89.
A copy constructor is called ……………..
a) When an object is passed as a parameter to any of the member functions
b) When a member function returns an object
c) When an object is passed by reference to an instance of its own class
d) All the above
Answer:
d) All the above

Question 90.
The constructors are executed in the …………………. of the object declared.
a) Order
b) Reverse order
c) Either A or B
d) None of these
Answer:
a) Order

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 91.
When the initial values are provided during runtime then it is called ………………….. initialization.
a) Static
b) Dynamic
c) Run time
d) None of these
Answer:
b) Dynamic

Question 92.
…………………. constructor can have parameter list.
a) Constructor
b) Destructor
c) Both A and B
d) None of these
Answer:
a) Constructor

Question 93.
No return type can be specified for ………………….
a) Constructor
b) Destructor
c) Both A and B
d) None of these
Answer:
c) Both A and B

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 94.
The ……………….. function can be overloaded.
a) Constructor
b) Destructor
c) Both A and B
d) None of these
Answer:
a) Constructor

Question 95.
The compiler generates a ………………… in the absence of a user-defined.
a) Constructor
b) Destructor
c) Both A and B
d) None of these
Answer:
a) Constructor

Question 96.
Compiler generated constructor is ………………….. member function.
a) private
b) protected
c) public
d) None of these
Answer:
c) public

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 97.
The ………………. is executed automatically,
a) Constructor
b) Destructor
c) Both A and B
d) None of these
Answer:
c) Both A and B

Question 98.
The ……………. is executed automatically when the object is created.
a) Constructor
b) Destructor
c) Both A and B
d) None of these
Answer:
a) Constructor

Question 99.
When a class object goes out of scope, a special function called the ………………. gets executed.
a) Constructor
b) Destructor
c) Both A and B
d) None of these
Answer:
b) Destructor

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 100.
The destructor has the same name as the class tag but prefixed with a …………………
a) ~ (tilde)
b) #
c) @
d) None of these
Answer:
a) ~ (tilde)

Question 101.
A …………………… is a special member function that is called when the lifetime of an object ends.
a) Constructor
b) Destructor
c) Both A and B
d) None of these
Answer:
b) Destructor

Question 102.
The ………………… cannot have arguments,
a) Constructor
b) Destructor
c) Both A and B
d) None of these
Answer:
b) Destructor

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 103.
There can be ……………… destructor in a class.
a) Two
b) Three
c) Only one
d) Four
Answer:
c) Only one

Question 104.
_____ cannot be inherited.
a) Constructor
b) Destructor
c) Both A and B
d) None of these
Answer:
c) Both A and B

Very Short Answer (2 Marks)

Question 1.
Define methods of a class and write its types.
Answer:
The class comprises members. Member functions are called methods. The member functions of a class can be defined in two ways.

  1. Inside the class definition
  2. Outside the class definition

Question 2.
Why classes are needed?
Answer:
Classes are needed to represent real-world entities that not only have data type properties but also have associated operations. It is used to create user-defined data types.

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 3.
What is called as nesting of member functions?
Answer:
Only the public members of a class can be accessed by the object of that class, using the dot operator. However, a member function can call another member function of the same class directly without using the dot operator. This is called as nesting of member functions.

Question 4.
What are the visibility labels of a class body?
Answer:
The class body has three visibility labels viz., private, public, and protected. The Visibility labels are also called as access specifiers.

Question 5.
What is a parameterized constructor?
Answer:
A constructor which can take arguments is called a parameterized constructor. This type of constructor helps to create objects with different initial values. This is achieved by passing parameters to the function.

Question 6.
What happened if all the members of a class are defined as private?
Answer:
If all members of the class are defined as private, then the class becomes frozen.
The object of the class can not access anything from the class.

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 7.
Write about objects.
Answer:
A class specification just defines the properties of a class. To make use of a class specified, the variables of that class type have to be declared. The class variables are called objects. Objects are also called an instance of the class.

For example:
student s;
In the above statement ‘s’ is an instance of the class student.

Question 8.
How many ways objects can be created for a class? Give its types.
Answer:
Objects can be created in two methods:

  1. Global object
  2. Local object

Question 9.
What do you mean by an array of objects?
Answer:
An array which contains the class type of element is called an array of objects. It is declared and defined in the same way as any other type of array.

Example:
class stock
{
int itemno;
float price; public:
}s[5];
Here s[5] is an array of objects.

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 10.
What is a nested member function?
Answer:
A member function can cal! another member function of the same class directly without using the dot operator. This is called as nesting of member functions.

Question 11.
How many ways objects can be passed to function argument?
Answer:
Objects can also be passed in both ways

  • Pass By Value
  • Pass By Reference

Question 12.
What is a container class?
Answer:
Whenever an object of a class is declared as a member of another class it is known as a container class. In the container-ship, the object of one class is declared in another class.

Question 13.
What is the need for a constructor in a class?
Answer:
Instantiating object is done using constructor. An array or a structure in C++ can be initialized during the time of their declaration using constructor. The constructor function initializes the class object.

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 14.
What are the functions of a constructor?
Answer:
The main functions of the constructor are:

  • To allocate memory space to the object and
  • To initialize the data member of the class object.

Question 15.
What is a default constructor?
Answer:
Default constructor:
A constructor that accepts no parameter is called the default constructor.
For example in the class Data program Data::Data( ) is the default constructor.
Using this constructor objects are created similar to the way the variables of other data types are created.

Example:
int num; //ordinary variable declaration
Data d1; // object declaration
If a class does not contain an explicit constructor the compiler automatically generates a default constructor implicitly as an inline public member.

Question 16.
What is the significance of default constructor?
Answer:
Default constructors are very useful to crate objects without having specific initial value. It is also used to create array of objects.

Question 17.
How many ways a constructor can be invoked?
Answer:
There are two ways to create an object using parameterized constructor:

  1. Implicit call
  2. Explicit call

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 18.
What is copy constructor?
Answer:
A constructor having a reference to an already existing object of its own class is called copy constructor.
In other words Copy Constructor is a type of constructor which is used to create a copy of an already existing object of a class type.

Question 19.
What is the order of constructor invocation?
Answer:
The constructors are executed in the order of the object declared. (If it is in same statement left to right)

For example:
Test t1;
Test t2; // the order of constructor execution is first for t1 and then for t2.
Consider the following example
Sample s1,s2,s3 ; //The order of construction is s1 then s2 and finally s3

Question 20.
What do you mean by dynamic initialization of Object?
Answer:
When the initial values are provided during runtime then it is called dynamic initialization.

Question 21.
Write a note on the destructor.
Answer:

  • When a class object goes out of scope, a special function called the destructor gets executed.
  • The destructor has the same name as the class tag but prefixed with a ~(tilde).
  • The destructor function also returns nothing and it does not associate with any data type

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 22.
What is the need for a destructor in a class?
Answer:
The purpose of the destructor is to free the resources that the object may have acquired during its lifetime. A destructor function removes the memory of an object which was allocated by the constructor at the time of creating an object

Question 23.
Define destructor.
Answer:
A destructor is a special member function that is called when the lifetime of an object ends and destroys the object constructed by the constructor. Normally it is declared under the public visibility of a class.

Short Answers (3 Marks)

Question 1.
Explain the local object with an example.
Answer:
If an object is declared within a function then it is called a local object.
It cannot be accessed from outside the function.
# include
# include
using namespace std
class add  //Global class
{
int a,b; public:
int sum; void
getdata()
{
a = 5; b = 10; sum
= a + b;
}
} a1;
add a2;
int main()
{
add a3;
a1.getdata();  //global object
a2.getdata();  //global object
a3.getdata();
cout << a1 .sum;  //Local object for a global class
cout << a2.sum;
cout << a3.sum;
return 0;   //public data member accessed from outside the class
}
Output:
151515

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 2.
Write about private, protected, and public members of a class.
Answer:
The Public Members:
A public member is accessible from anywhere outside the class but within a program.

The Private Members:
A private member cannot be accessed from outside the class. Only the class member functions can access private members. By default, all the members of a class would be private.

The Protected Members:
A protected member is very similar to a private member but they can be accessed in child classes which are called derived classes (inherited classes).

Question 3.
What is a constructor?
Answer:
The definition of a class only creates a new user-defined data type. The instances of the class type should be instantiated (created and initialized). Instantiating objects is done using the constructor. An array or a structure in C++ can be initialized during the time of their declaration.

The initialization of a class type object at the time of declaration similar to a structure or an array is not possible because the class members have their associated access specifiers (private or protected or public). Therefore Classes include special member functions called constructors. The constructor function initializes the class object.

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 4.
Explain memory allocation of objects.
Answer:
Memory allocation of objects:
All the objects belonging to that class use the same member function, no separate space is allocated for member functions when the objects are created.
Memory space required for the member variables are only allocated separately for each object because the member variables will hold different data values for different objects.
Memory for Objects for p1 and p2 is illustrated:
Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects 5

Question 5.
Explain the default constructor with an example.
Answer:
A constructor that accepts no parameter is called the default constructor. For example in the class data program Data::Data() is the default constructor. Using this constructor objects are created similar to the way the variables of other data types are created.

Example:
int num; //ordinary variable declaration
Data d1; // object declaration

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 6.
How will you refer members of the class? Give its syntax and an example.
Answer:
The members of a class are referenced (accessed) by using the object of the class followed by the dot (membership) operator and the name of the member.

The general syntax for calling the member function is:
Object_name.function_name (actual parameter); For example consider the following illustration:
Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects 6

Question 7.
Explain the different methods of passing an object to the function argument.
Answer:
Pass By Value:
When an object is passed by value the function creates its own copy of the object and works on it. Therefore any changes made to the object inside the function do not affect the original object.

Pass By Reference:
When an object is passed by reference, its memory address is passed to the function so the called function works directly on the original object used in the function call. So any changes made to the object inside the function definition are reflected in the original object.

Question 8.
Write about constructor.
Answer:
When an instance of a class comes into scope, a special function called the constructor gets executed. The constructor function name has the same name as the class name. The constructors return nothing. They are not associated with any data type. It can be defined either inside class definition or outside the class definition.

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 9.
What is a parameterized constructor?
Answer:
Parameterized Constructors:
A constructor which can take arguments is called a parameterized constructor. This type of constructor helps to create objects with different initial values. This is achieved by passing parameters to the function.

Example:
class simple
{
private:
int a,b;
public:
simple(int m, int n)
{
a= m ;
b= n;
cout< < “\n Parameterized Constructor of class-simple
}
};

Question 10.
What do you mean by the implicit and explicit call of a constructor?
Answer:
Implicit call:
In this method, the parameterized constructor is invoked automatically whenever an object is created.
For example, simple s1(10,20); in this for creating the object si parameterized constructor is automatically invoked

Explicit call:
In this method, the name of the constructor is explicitly given to invoking the parameterized constructor so that the object can be created and initialized.

For example:
simple s1=simple(10,20); //explicit call

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 11.
When copy constructor Is executed? Give examples.
Answer:
A copy constructor is called

  • When an object is passed as a parameter to any of the member functions
    Example: void simple: :putdata(simple x);
  • When a member function returns an object
    Example: simple get data( ) { }
  • When an object is passed by reference to an instance of its own class
    For example: simple1, s2(s1); // s2(s1) calls copy constructor

Explain in Detail (5 Marks)

Question 1.
Explain how to define class members?
Answer:
Definition of class members:
Class comprises of members. Members are classified 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.
  • Member functions are called methods, and data members are also called attributes.

Example:

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects 7
Defining methods of a class:
Without defining the methods (functions), class definition will become incomplete. The member functions of a class can be defined in two ways.

  • Inside the class definition
  • Outside the class definition

Inside the class definition:
When a member function is defined inside a class, it behaves like inline functions. These are called Inline member functions.

Outside the class definition:
When Member function defined outside the class just like normal function definition (Function definitions you are familiar with) then it is being called as an outline member function or non-inline member function. Scope resolution operator (::) is used for this purpose.

The syntax for defining the outline member function is:
return_type class_name :: function name (parameter list)
{
function definition
Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects 8

Class using Inline and Outline member function:
# include<iostream>
using namespace std;
class Box
{
// no access specifier mentioned
double width;
public:
double length;
//inline member function definition
void printWidth( )
{
cout<<“\n The width of the box is…”<<width;
}
//prototype of the function
void setWidth(double w);
};
// outline member function definition
void Box :: setWidth(double w)
{
width=w;
}
int main( )
{
// object for class Box
Box b;
// Use member function to set the width.
b.setWidth(10.0);
//Use member function to print the width.
b.printWidth( );
return 0;
Output
The width of the box is… 10

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 2.
What are the ways to create an object using the parameterized constructor with an example?
Answer:
There are two ways to create an object using the parameterized constructor:
1. Implicit call: In this method, the parameterized constructor is invoked automatically whenever an object is created. For example, simple s1( 10,20); in this, for creating the object s1 parameterized constructor is automatically invoked.

2. Explicit call: In this method, the name of the constructor is explicitly given to invoking the parameterized constructor so that the object can be created and initialized.

#include
using namespace std;
class simple
{
private:
int a, b;
public:
simple(int m,int n)
{
a = m;
b = n;
cout << “\n Constructor of class – simple invoked for implicit and explicit call” << endl;
}
void putdata()
{
cout << “\n The two integers are…” << a << ‘\t’ << b << endl;
cout << “\n The sum of the variables” << a << “+” << b << “=” << a + b;
}
};
int main()
{
simple s1(10,20); //implicit call
simple s2 = simple(30,45); //explicit call
cout << “\n\t\tObject 1\n”;
s1.putdata();
s2.putdata();
return 0;
}
Output:
Constructor of class – simple invoked for the implicit and explicit call
Constructor of class-simple invoked for the implicit and explicit call

Object 1
The two integers are… 10 20
The sum of the variables 10 + 20 = 30

Object 2
The two integers are… 30 45.
The sum of the variables 30 + 45 = 75

Question 3.
What are the characteristics of a destructor?
Answer:
Characteristics of destructors:

  • The destructor has the same name as that of the class prefixed by the tilde character
  • The destructor cannot have arguments.
  • It has no return type.
  • Destructors cannot be overloaded i.e., there can be only one destructor in a class.
  • In the absence of a user-defined destructor, it is generated by the compiler.
  • The destructor is executed automatically when the control reaches the end of the class scope to destroy the object.
  • They cannot be inherited.

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Evaluate Yourself

Question 1.
Define a class in general and in C++’s context.
Answer:
Classes represent real-world entities that not only have data type properties but also have associated operations.
In C++ class is a way to bind the data and its associated functions together. It is a user-defined data type.

Question 2.
What is the purpose of a class specifier?
Answer:
Data hiding is one of the important features of Object Oriented Programming which allows preventing the functions of a program to access directly the internal representation of a class type.
The access restriction to the class members is specified by class specifies like public, private, and protected sections within the class body.

Question 3.
Compare a structure and a class in C++ context.
Answer:
The only difference between structure and class is the members of structure are by default public where as it is private in class.

Question 4.
Compare private and public access specifier.
Answer:
Public members:
A public member is accessible from anywhere outside the class but within a program. We can set and get the value of public data members even without using any member function.

Private members:
A private member cannot be accessed from outside the class. Only the class member functions can access private members. By default all the members of a class would be private.

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 5.
What is a non-inline member function? Write its syntax.
Answer:
When Member function defined outside the class just like normal function definition (Function definitions you are familiar with) then it is being called as an outline member function or non-inline member function. Scope resolution operator (::) is used for this purpose.
The syntax for defining the outline member function is:
Syntax:
return_type class_name :: function_name (parameter list)
{
function definition
}
Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects 9

Activity – 1
State the reason for the invalidity of the following code fragment.

(i)

(ii)

class count
{
int first
int second;
public:
int first
};
class item
{
int prd;
};
int prdno;

Answer:

  • Data member first is duplicated and it is defined with two scopes( both private and public). It is invalid.
  • Object name prefix with the only class name. No data type allowed in between class name and object name.

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Activity – 2
class area
{
int s;
public:
void calc( );
};
Write an outline function definition for calc( ); which finds the area of a square
Answer:
int area :: calc( ) .
{
return(s * s);
}

Activity – 3
Identify the error in the following code fragment
class A
{
float x;
void init( )
{
Aa1;
X1.5=1; .
}
};
void main( )
{
A1.init( );
}
Answer:
Error:
Local object can not be accessed from outside the function. Al is the local object, so it can not be accessed in main( );

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Activity – 4
What is the size of the objects s1, s2?
class sum
{
int n1,n2;
public:
void add( )
{
int n3=10;n1=n2=10;
}
} s1,s2;
Answer:
The size of the object SI and S2 is 8 bytes each in Dev C++, In Turbo C++ 4 bytes each.
Program to test the memory requirement:
class sum
{
int n1,n2;
public:
void add( )
{
int n3-10;
n1=n2=10;
}
} s1,s2;
using namespace std;
#include<iostream>
int main( )
{
cout<<sizeof(s1)<< “”<<sizeof(s2);
}
Output
Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects 10

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Activity – 5
i) Write member function called display with no return.
class objects.
ii) Try the output of the above coding with the necessary modifications.
PROGRAM
#indude<iostream>
using namespace std;
class compute
{
int n1, n2;
public :
void init (int a, int b)
{
n1 = a;
n2 = b;
}
int n;
int add ( )
return (n1+n2);;
{
int prd ( )
{
return (n1*n2);
}
};
compute c1, c2;
void display(compute &objl,compute &obj2)
{
c1.init(12,15);
c2.init(8,4);
objlm = obj1.add( );
obj2.n = obj2.add( );
cout<<“\n Sum of object-1 “<<obj1.n;
cout<<“\n Sum of object-2 “<<obj2.n;
cout<<“\n Sum of the two objects are”<<obj1.
n+obj2.n;
c1.init(5,4);
c2.init(2,5);
obj1.n = obj1.prd( );
obj2.n = obj2.prd( );
cout<<“\n Product of object-1 “<<objl.n;
cout<<“\n Product of object-2 “<<obj2.n;
cout<<“\n Product of the two objects are “<<objl.n*obj2.n;
}
int main( )
{
display(c1,c2);
return 0;
}
output
Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects 11

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Activity – 6
#include<iostream>
using namespace std;
class Sample
{
int i,j;
public :
int k;
Sample( )
{
i=j=k=0;//constructor defined inside the class
}
};
int main( )
{
Sample s1;
return 0;
}
Output
In the above program justify your reason for no output.
Answer:
Constructor alone is defined without output statement. When the above program is executed, the constructor executed. But no output on the screen because of missing cout

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Hands-On Practice

Question 1.
Define a class employee with the following specification.
Answer:
private members of class Employee
empno- integer
ename – 20 characters
basic-float
netpay, hra, da, – float
calculate ( ) – A function to find the basic+hra+da with float return type

public member functions of class employee
havedata( ) – A function to accept values for empno, ename, basic, hra,
da and call calculate( ) to compute netpay
dispdata( ) – A function to display all the data members on the screen
PROGRAM
using namespace std;
#include<iostream>
#include<iomanip>
class Employee
{
private :
int empno;
char ename[20];
float basic,hra,da,netpay;
float calculate( )
{
return (basic+hra+da);
}
public:
void have data( )
{
cout<<setw(35)<<“Enter Employee number :”;
cin>>empno;
cout<<setw(35)<<“Enter Employee name :”;
cin>>ename;
cout<<setw(35)<<“Enter Basic pay :”;
cin>>basic; ,
cout<<setw(35)<<“Enter House Rent Allowance (HRA):”;
cin>>hra; .
cout<<setw(35)<<“Enter Dearness Allowance (DA):”;
cin>>da;
netpay = calculate( );
}
void dispdata( )
{
cout<<“\nEMPLOYEE DETAILS\n\n”;
cout<<setw(35)<<“Employee number :”<<empno<<endl;
cout<<setw(35)<<“Employee name :”<<ename<<endl;
cout<<setw(35)<<“Basic pay :”<<basic<<endl;
cout<<setw(35)<<“House Rent Allowance (HRA) :”<<hra<<endl; cout<<setw(35)<<“Dearness Allowance (DA) :”<<da<<endl;
cout<<setw(35)< <“Netpay :”<<netpay<<endl;
}
};
int main( )
{
Employee e;
e.havedata( );
e.dispdata( );
}
Output
Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects 12

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 2.
Define a class MATH with the following specifications.
Answer:
private members:
num1, num2, result – float
init( ) function to initialize num1, num2 and result to zero .

protected members:
add( ) function to add num1 and num2 and store the sum in result
diff( ) function to subtract num1 from num2 and store the difference in the result

public members:
getdata( ) function to accept values for num1 and num2
menu( ) function to display menu
1. Add…
2. Subtract…
invoke add() when the choice is 1 and invoke prod when the choice is 2 and also display the result.
PROGRAM
using namespace std;
#include<iostream>
#include<iomanip>
class MATH
{
private:
float num1,num2,result;
init( )
{
num1=0;
num2=0;
result=0;
}
protected: void add( )
{
result = num1+num2;
}
void diff( )
{
result = num1 – num2;
}
public:
getdata( )
{
cout<<“\nEntertwo numbers “;
cin>>num1>>num2;
} ‘ menu( )
{
int choice;
cout<<“\n1.Add …”;
cout<<“\n2.Subtract …….”;
cout<<“\nEnter your choice :”; cin>>choice;
switch(choice)
{
case 1: getdata( );
add( );
cout<<“\nAdded value is”<<result;
break;
case 2: getdata( );
diff( );
cout<<“\nSubtracted value is “<<result;
break;
default: cout<<“\End”;
}
}
};
int main( )
{
MATH m;
m. menu( );
}
Output
Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects 13

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 3.
Create a class called Item with the following specifications.
Answer:
private members:
code, quantity- Integer data type
price – Float data type
getdata( )-function to accept values for all , data members with no return

public members:
taxt – float
dispdata( ) member function to display code,quantity,price and tax .The tax is calculated as if the quantity is more than 100 tax is 2500 otherwise 1000.
PROGRAM
using namespace std;
#include<iostream>
#include<iomanip>
class Item
{
private:
int code,quantity;
float price;
void getdata( )
{
cout<<“\nEnter product code “; cin>>code;
cout<<“\nEnter quantity “; cin>>quantity;
cout<<“\nEnter price “; cin>> price;
}
public:
float tax;
void display( )
{
getdata( );
if(quantity>100)
tax = 2500;
else
tax = 1000;
cout<<endl<<setw(25)<< “Product code : “<<code<<endl<<endl;
cout<<setw(25)<<“Quantity : ” <<quantity<<endl<<endl;
cout<<setw(25)<<“Unit price :” <<price<<endl<<endl;
cout<<setw(25)<<“Total Amount: ” < cout<<setw(25)<<“Net Bill amount : ”
<<quantity* price+tax<<endl<<endl;
}
};
int main( )
{
Item i; i.display( );
}
Output
Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects 14

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 4.
Write the definition of a class FRAME in C++ with the following description.
Answer:
Private members:
FramelD – Integer data type
Height, Width, Amount – Float data type
SetAmount( ) -Member function to calculate and assign amount as 10*Height*Width

Public members:
GetDetail( ) Afunction to allow user to entervalues of FramelD, Height, Width. This function should also call SetAmount() to calculate the amount.
ShowDetail( ) A function to display the values of all data members.
PROGRAM
using namespace std;
#include<iostream>
#include<iomanip>
class FRAME
{
private:
int FrameId;
float Height, Width, Amount;
void SetAmount()
{
Amount = 10 * Height * Width;
}
public:
void Getdetails( )
{
cout<<“\nEnter Frame Id : “; cin>> FrameId;
cout<<“\nEnter Frame Height: cin>> Height;
cout<<“\nEnter Frame Width : “; cin>>Width;
SetAmount( );
}
void ShowDetaiis( )
{
cout<<endl<setw(25)<<“Frame Id :” <<FrameId<<endl<<endl; cout<<setw(25)<<“Frame Height:” <<Height<<endl<endl;
cout<<setw(25)<<“Frame Width :”<<Width<<endk<endl;
cout<<setw(25)<<“Total Amount:”
<<Amount< <endl< <endl;
}
int main( )
{
FRAME F;
F.Getdetails( );
F.ShowDetails( );
}
Output
Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects 15

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 5.
Define a class RESORT in C++ with the following description:
Answer:
Private Members:
Rno //Data member to store Room No
RName //Data member to store customer name
Charges //Data member to store per day charges Days //Data member to store a number of days of stay
COMPUTE( ) //A function to calculate and return Amount as
//Days*Chagres and if the value of Days*Charges is more than 5000 then as 1.02*Days*Charges

Public Members:
Getinfo( ) //A function to enter the content Rno, Name, Charges //and Days Displayinfo( ) //A function to display Rno, RName, Charges, Days and
// Amount (Amount to displayed by calling function COMPUTE())
PROGRAM
using namespace std;
#include<iostream>
class RESORT
{
private:
int Rno,Days,Charges;
char Rname[20];
int compute( )
{
if (Days * Charges >5000)
return (Days * Charges * 1.02);
else
return(Days * Charges);
}
public:
getinfo( )
{
cout<<“\nEnter customer name :”;
cin>>Rname;
cout<<“\nEnter charges per day :”;
cin>>Charges;
cout<<“\nEnter Number of days :”;
cin>>Days;
cout<<“\nEnter Room Number :”;
cin>>Rno;
}
dispinfo( )
{
cout<<“\nRoom Number : “<<Rno;
cout<<“\nCustomer name :
“<<Rname;
cout«”\nCharges per day :
“<<Charges;
cout<<“\nNumber of days :
“<<Days;
cout<<“\nTotal Amount :
“<<compute( );
}
};
int main( )
{
RESORT Obj;
Obj.getinfo( );
Obj.dispinfo( );
}
Output
Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects 16

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 7.
Answer:
struct pno
{
int pin;
float balance;
}
Create a BankAccount class with the following specifications

protected members
pno_obj //array of 10 elements
init(pin) // to accept the pin number and initialize it and initialize
// the balance amount is 0

public members
deposit(pin, amount):
Increment the account balance by accepting the amount and pin. Check the pin number for matching. If it matches increment the balance and display the balance else display an appropriate message withdraw(self, pin, amount):
Decrement the account balance by accepting the amount and pin. Check the pin number for matching and balance is greater than 1000 and amount is less than the balance. If it matches withdraw the amount and display the balance else display an appropriate message
PROGRAM
using namespace std;
#include<iostream>
#include<iomanip>
struct pno
{
int pin;
float balance;
};
class BankAccount
{
public:
pno pno_obj[10];
void deposit(int pn,float amt)
{
for(int i=0;i<10;i++)
if(pno_obj[i].pin == pn)
{
pno_obj[i].balance = pno_obj[i].balance + amt;
cout<<“\nTransaction successful!
cout<<“\nBalance amount in your account is”<< pno_obj[i].balance; break;
}
void withdraw(int self,int pn,float amt)
{
for(int i=0;i<10;i++)
{
if(pno_obj[i].pin== pn)
{
if (pno_obj[i].balance>1000 && amt < pno_obj[i].balance)
{
pno_obj[i].balance=pno_obj[i]. balance- amt;
cout<<“\nTransaction successful”;
cout<<“\nBalance amount in your account is “<< pno_obj[i].balance; break;
}
} }
}
};
int main( )
{
int pin_no, tamt;
BankAccount b;
// initialization of objects with pin and balance amount as 0
for(int i=0;i<10;i++)
{
b.pno_obj[i].pin=i+l;
}
int choice;
while(choice !=3)
{
cout <<“\n1. Deposit”;
cout <<“\n2.Withdrawal”;
cout<<“\n3.Exit”;
cout<<“\nEnter your choice “; cin >>choice;
switch(choice)
{
case 1:
cout<<“\nEnter PIN
cin>>pin_no;
cout<<“\nEnter Deposit amount”;
cin>>tamt;
b.deposit(pin_no,tamt); break;

case 2:
cout<<“\nEnter PIN cin>>pin_no;
cout<<“\nEnter Withdrawal amount”;
cin>>tamt;
cout<<“\nEnter 1 for Self 2 for Others :”;
int type;
cin>>type;
b.withdraw(type,pin_no,tamt); break;
default: cout<<“\nTransaction completed”;
}
}
}
Output
Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects 17

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 8.
Define a class Hotel in C++ with the following description:
Answer:
Private Members:
Rno //Data member to store Room No
Name //Data member t store customer name
Charges //Data member to store per day charges
Days //Data member to store number of days of stay
Calculate() //A function to calculate and return Amount as
//Days*Chagres and if the value of Days*Charges is more than 12000 then as 1.2*Days*Charges

Public Members:
Hotel( ) //to initialize the class members
Getinfo( ) //A function to enter the content Rno, Name, Charges //and Days
Showinfo( ) //A function to display Rno, RName, Charges, Days and
//Amount (Amount to displayed by calling function CALCULATE( ))
PROGRAM
using namespace std;
#include<iostream>
#include<string.h>
class Hotel
private:
int Rno,Days,Charges;
char Name[20];
1 int Calculate( )
{
if (Days * Charges >12000)
return (Days * Charges * 1.02);
else
return(Days * Charges);
}
public:
Hotel( )
{
Rno=0;
Days=0;
Charges=0;
strcpy(Name,””);
}
void Getinfo( )
{
cout<<“nEnter customer name :”;
cin>>Name;
cout<<“nEnter charges per day : “;
cin>>Charges;
cout<<“\nEnter Number of days :”;
cin>>Days;
cout<<“\nEnter Room Number :”;
cin>>Rno;
}
void Showinfo( )
{
cout<<“\nRoom Number: “<<Rno;
cout<<“\nCustomer name : “<<Name;
cout<<“\nCharges per day : “<<Charges;
cout<<“\nNumber of days : “<<Days;
cout<<“\nTota! Amount: “<<Calculate( );
}
};
int main( )
{
Hotel obj;
obj.Getinfo( );
obj.Showinfo( )
}
Output
Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects 18

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 9.
Define a class Exam in C++ with the following description:
Answer:
Private Members:
Rollno – Integer data type
Cname – 25 characters
Mark – Integer data type

public:
Exam(int,char[],int) //to initialize the object ~Exam() // display message “Result will be intimated shortly”
void Display( ) // to display all the details if the mark is above 60 other wise display “Result Withheld”
PROGRAM
using namespace std;
#include<iostream>
#include<string.h>
class Exam
{
private:
int Rollno,Mark;
char Cname[25];
public:
Exam(int r,char n[25],int m)
{
Rollno = r;
Mark = m;
strcpy(Cname,n);
}
~Exam( )
{
cout<<“\n\nResult will be intimated shortly”;
}
void Display( )
{
if (Mark>60)
{
cout<<“\n\nRoll Number : “<<Rollno;
cout<<“\nCandidate name : “<<Cname;
cout<<“\nMark :”<<Mark;
}
else
{
cout<<“\n\nRoll Number : “<<Rollno;
cout<<“\nCandidate name : “<<Cname;
cout<<“\nResult Withheld”;
}
}
};
int main( )
{
Exam obj 1(1011,”SURYA”,78),obj2( 1012,”JOHN”,44);
objl.Display( );
obj2. Display( );
}
Output
Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects 19

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Question 10.
Define a class Student in C++ with the following specification:
Answer:
Private Members:
A data member Rno(Registration Number) type long
A data member Cname of type string A data member Agg_marks (Aggregate Marks) of type float
A data member Grade of type char
A member function setGrade () to find the grade as per the aggregate marks obtained by the student. Equivalent aggregate marks range and the respective grade as shown below.
Aggregate Marks -Grade
>=90 – A
Less than 90 and >=75 – B
Less than 75 and >=50 – C
Less than 50 – D
Public members:
A constructor to assign default values to data members:
A copy constructor to store the value in another object
Rno=0, Cname=”N.A” Agg_marks=0,0
A function Getdata ( ) to allow users to enter values for Rno.Cname, Aggjnarks and call functionsetGrade ( ) to find the grade.
A function dispResult( ) to allow user to view the content of all the data members.
A destructor to display the message “END”
PROGRAM .
using namespace std;
#include<iostream>
#include<string.h>
#include<iomanip>
class Student
{
private:
long Rno;
char Cname[25],Grade;
float Agg_marks;
void Setgrade()
{
if (Ag g_ma rks >=90)
Grade = ‘A’;
else if(Agg_marks>=75)
Grade = ‘B’;
else if(Agg_marks>=50)
Grade = ‘C’;.
else
Grade = ‘D’;
}
public:
Student( )
{
Rno = 0;
Agg_marks = 0;
strcpy(Cname,””);
Grade=”;
}
Student(Student &s) .
{
Rno = s.Rno;
Agg_marks = s.Agg_marks;
strcpy(Cname,s.Cname);
Grade=s.Grade;

~Student( )
{
cout<<“\nEND”; >
void Getdata( )
{
cout<<“\nEnter Register Number”;
cin>>Rno;
cout<<“\nEnter Candidate Name
cin>>Cname;
cout<<“\nEnter Aggrigate Mark”;
cin>>Agg_marks;
Setgrade( );
}
void dispResult( )
{
cout<<setw(30)<<“Candidate Register Number
“<<Rno<<endl<<endl;
cout< <setw(30)<< “Candidate Name : “<<Cname<<endk<endI;
cout<<setw(30)<<“Aggrigate Mark : “<<Agg_marks«endk<endl;
cout<<setw(30)<<“Grade :
“<<Grade<<endk<endl;
}
};
int main( )
{
Student s1;
s1.Getdata( );
Student s2(s1);
COut<<“\nFIRST CANDIDATE DETAIL \n\n”; s1.dispResult( );
cout<<“\nSECOND CANDIDATE DETAIL \n\n”;
s2.dispResult( );
}
Output
Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects 20

Samacheer Kalvi 11th Computer Science Guide Chapter 14 Classes and Objects

Samacheer Kalvi 11th Computer Science Guide Chapter 13 Introduction to Object-Oriented Programming Techniques

Tamilnadu State Board New Syllabus Samacheer Kalvi 11th Computer Science Guide Pdf Chapter 13 Introduction to Object-Oriented Programming Techniques Text Book Back Questions and Answers, Notes.

Tamilnadu Samacheer Kalvi 11th Computer Science Solutions Chapter 13 Introduction to Object-Oriented Programming Techniques

11th Computer Science Guide Introduction to Object-Oriented Programming Techniques Text Book Questions and Answers

Book Evaluation

Part I

Choose The Correct Answer

Question 1.
The term is used to describe a programming approach based on classes and objects is
a) OOP
b) POP
c) ADT
d) SOP
Answer:
a) OOP

Question 2.
The paradigm which aims more at procedures.
a) Object Oriented Programming
b) Procedural programming
c) Modular programming
d) Structural programming
Answer:
b) Procedural programming

Samacheer Kalvi 11th Computer Science Guide Chapter 13 Introduction to Object-Oriented Programming Techniques

Question 3.
Which of the following is a user defined data type?
a) class
b) float
c) int
d) object
Answer:
a) class

Question 4.
The identifiable entity with some characteristics and behaviour is.
a) class
b) object
c) structure
d) member
Answer:
b) object

Samacheer Kalvi 11th Computer Science Guide Chapter 13 Introduction to Object-Oriented Programming Techniques

Question 5.
The mechanism by which the data and functions are bound together into a single unit is known as
a) Inheritance
b) Encapsulation
c) Polymorphism
d) Abstraction
Answer:
b) Encapsulation

Question 6.
Insulation of the data from direct access by the program is called as
a) Data hiding
b) Encapsulation
c) Polymorphism
d) Abstraction
Answer:
a) Data hiding

Question 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
Answer:
d) Abstraction

Samacheer Kalvi 11th Computer Science Guide Chapter 13 Introduction to Object-Oriented Programming Techniques

Question 8.
Which of the following is the most important advantage of inheritance?
a) data hiding
b) code reusability
c) code modification
d) accessibility
Answer:
b) code reusability

Question 9.
“Write once and use it multiple time” can be achieved by
a) redundancy
b) reusability
c) modification
d) composition
Answer:
b) reusability

Question 10.
Which of the following supports the transitive nature of data?
a) Inheritance
b) Encapsulation
c) Polymorphism
d) Abstraction
Answer:
a) Inheritance

Samacheer Kalvi 11th Computer Science Guide Chapter 13 Introduction to Object-Oriented Programming Techniques

Part – II

Very Short Answer

Question 1.
How is modular programming different from the procedural programming paradigm?
Answer:
Modular programming:

  • Emphasis on the algorithm rather than data.
  • Programs are divided into individual modules.
  • Each modules are independent of each other and have their own local data.
  • Modules can work with their own data as well as with the data passed to it.

Procedural programming:

  • Programs are organized in the form of subroutines or subprograms.
  • All data items are global.
  • Suitable for a small-sized software applications.
  • Difficult to maintain and enhance the program code as any change in data type needs to be propagated to all subroutines that use the same data type.

Question 2.
Differentiate classes and objects.
Answer:
Class: A Class is a construct in C++ which is used to bind data and its associated function together into a single unit using the encapsulation concept. Class is a user-defined data type.

Object: An identifiable entity with some characteristics and behaviour is called an object.

Samacheer Kalvi 11th Computer Science Guide Chapter 13 Introduction to Object-Oriented Programming Techniques

Question 3.
What is polymorphism?
Answer:
Polymorphism is the ability of a message or function to be displayed in more than one form.

Question 4.
How are encapsulation and abstraction are interrelated?
Answer:
The mechanism by which the data and functions are bound together into a single unit is known as Encapsulation. It implements abstraction.
Abstraction refers to showing only the essential features without revealing background details.

Question 5.
Write the disadvantages of OOP.
Answer:

  1. Size: Object-Oriented Programs are much larger than other programs.
  2. Effort: Object-Oriented Programs require a lot of work to create.
  3. Speed: Object-Oriented Programs are slower than other programs, because of their size.

Samacheer Kalvi 11th Computer Science Guide Chapter 13 Introduction to Object-Oriented Programming Techniques

Part – III

Short Answers

Question 1.
What is a paradigm? Mention the different types of paradigm.
Answer:
The paradigm means organizing principle of a program. It is an approach to programming.
There are different approaches available for problem-solving using computers. They are:

  • Procedural programming,
  • Modular Programming and
  • Object-Oriented Programming.

Question 2.
Write a note on the features of procedural programming.
Answer:
Important features of procedural programming

  1. Programs are organized in the form of subroutines or subprograms
  2. All data items are global
  3. Suitable for small-sized software application
  4. Difficult to maintain and enhance the program code as any change in data type needs to be propagated to all subroutines that use the same data type. This is time-consuming.
  5. Example: FORTRAN and COBOL.

Samacheer Kalvi 11th Computer Science Guide Chapter 13 Introduction to Object-Oriented Programming Techniques

Question 3.
List some of the features of modular programming
Answer:
Important features of modular programming:

  • Emphasis on the algorithm rather than data.
  • Programs are divided into individual modules.
  • Each modules are independent of each other and have their own local data.
  • Modules can work with its own data as well as with the data passed to it.
  • Example: Pascal and C.

Question 4.
What do you mean by modularization and software reuse?
Answer:

  1. Modularization: where the program can be decomposed into modules.
  2. Software reuse: where a program can be composed of existing and new modules.

Question 5.
Define information hiding.
Answer:
The data is not accessible to the outside world, and only those functions which are wrapped in the class can access it.These functions provide the interface between the object’s data and the program.
This encapsulation of data from direct access by the program is called data hiding or information hiding.

Samacheer Kalvi 11th Computer Science Guide Chapter 13 Introduction to Object-Oriented Programming Techniques

Part-IV

Explain in Detail

Question 1.
Write the differences between object-oriented programming and procedural programming.
Answer:
Object-Oriented Programming:

  • Emphasizes data rather than algorithms.
  • Data abstraction is introduced in addition to procedural abstraction.
  • Data and its associated operations are grouped into a single unit.
  • Programs are designed around the data being operated.
  • Example: C++, Java, VB.Net, Python

Procedural Programming:

  • Programs are organized in the form of subroutines or subprograms.
  • All data items are global.
  • Suitable for a small-sized software application.
  • Difficult to maintain and enhance the program code as any change in data type needs to be propagated to all subroutines that use the same data type.
  • Example: FORTRAN and COBOL

Samacheer Kalvi 11th Computer Science Guide Chapter 13 Introduction to Object-Oriented Programming Techniques

Question 2.
What are the advantages of OOPs?
Answer:
Advantages of OOP Re-usability:
“Write once and use it multiple times” you can achieve this by using class.

Redundancy:
Inheritance is a good feature for data redundancy. If you need the same functionality in multiple classes you can write a common class for the same functionality and inherit that class to sub-class.

Easy Maintenance:
It is easy to maintain and modify existing code as new objects can be created with small differences to existing ones.

Security:
Using data hiding and abstraction only necessary data will be provided thus maintains the security of data.

Question 3.
Write a note on the basic concepts that support OOPs?
Answer:
Object-Oriented Programming has been developed to overcome the drawbacks of procedural and modular programming. It is widely accepted that object-oriented programming is the most important and powerful way of creating software.

The Object-Oriented Programming approach mainly encourages:

  1. Modularization: where the program can be decomposed into modules.
  2. Software reuse: where a program can be composed of existing and new modules.

Main Features of Object-Oriented Programming:

  1. Data Abstraction
  2. Encapsulation
  3. Modularity
  4. Inheritance
  5. Polymorphism

Encapsulation:
The mechanism by which the data and functions are bound together into a single unit is known as Encapsulation. It implements abstraction. Encapsulation is about binding the data variables and functions together in class. It can also be called data binding. Encapsulation is the most striking feature of a class.

The data is not accessible to the outside world, and only those functions which are wrapped in the class can access it. These functions provide the interface between the object’s data and the program. This 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 which operate on these attributes. 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 functions.

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.

Samacheer Kalvi 11th Computer Science Guide Chapter 13 Introduction to Object-Oriented Programming Techniques

11th Computer Science Guide Introduction to Object-Oriented Programming Techniques Additional Questions and Answers

Choose The Correct Answer (1 Mark)

Question 1.
In procedural programming all data items are ……………….
(a) Cobol
(b) global
(c) fortran
(d) class
Answer:
(b) global

Question 2.
The object-oriented paradigm allows us to organize software as a collection of objects that consist of …………………..
a) Data
b) Behaviour
c) Both data and behaviour
d) None of these
Answer:
c) Both data and behaviour

Samacheer Kalvi 11th Computer Science Guide Chapter 13 Introduction to Object-Oriented Programming Techniques

Question 3.
………………. is an example of object-oriented programming.
(a) Python
(b) Java
(c) VB.Net
(d) All the above
Answer:
(d) All the above

Question 4.
Paradigm means ………………..
a) Organizing principle of a program
b) An approach to programming
c) Either A or B
d) None of these
Answer:
c) Either A or B

Question 5.
………………. is about binding the data variables and functions together in class.
(a) Data abstraction
(b) Modularization
(c) Redundancy
(d) Encapsulation
Answer:
(d) Encapsulation

Samacheer Kalvi 11th Computer Science Guide Chapter 13 Introduction to Object-Oriented Programming Techniques

Question 6.
In ………………. approach programs are organized in the form of subroutines or subprograms.
a) Modular Programming
b) Procedural Programming
c) Object-Oriented Programming
d) All the above
Answer:
b) Procedural Programming

Question 7.
…………………. approach of the program is time-consuming.
a) Modular Programming
b) Procedural Programming
c) Object-Oriented Programming
d) All the above
Answer:
b) Procedural Programming

Samacheer Kalvi 11th Computer Science Guide Chapter 13 Introduction to Object-Oriented Programming Techniques

Question 8.
……………… language is based on procedural programming.
a) FORTRAN
b) COBOL
c) Both A and B
d) C++
Answer:
c) Both A and B

Question 9.
…………….. paradigm consists of multiple modules; each module has a set of functions of related types.
a) Modular Programming
b) Procedural Programming
c) Object-Oriented Programming
d) All the above
Answer:
a) Modular Programming

Question 10.
In ……………… approach data is hidden under the modules
a) Modular Programming
b) Procedural Programming
c) Object-Oriented Programming
d) All the above
Answer:
a) Modular Programming

Samacheer Kalvi 11th Computer Science Guide Chapter 13 Introduction to Object-Oriented Programming Techniques

Question 11.
______ language is based on modular programming.
a) Pascal
b) C
c) Both A and B
d) C++
Answer:
c) Both A and B

Question 12.
………………. paradigm emphasizes the data rather than the algorithm.
a) Modular Programming
b) Procedural Programming
c) Object-Oriented Programming
d) All the above
Answer:
c) Object-Oriented Programming

Question 13.
………………… implements programs using classes and objects.
a) Modular Programming
b) Procedural Programming
c) Object-Oriented Programming
d) All the above
Answer:
c) Object-Oriented Programming

Samacheer Kalvi 11th Computer Science Guide Chapter 13 Introduction to Object-Oriented Programming Techniques

Question 14.
A …………….. is a construct in C++ which is used to bind data and its associated function together into a single unit.
a) Class
b) Structure
c) Array
d) None of these
Answer:
a) Class

Question 15.
A Class is a construct in C++ which uses the ……………….. concept.
a) Polymorphism
b) Encapsulation
c) Abstraction
d) Inheritance
Answer:
b) Encapsulation

Samacheer Kalvi 11th Computer Science Guide Chapter 13 Introduction to Object-Oriented Programming Techniques

Question 16.
Class is a ……………… data type.
a) User-defined
b) Derived
c) Primitive
d) None of these
Answer:
a) User-defined

Question 17.
…………………. can be defined as a template or blueprint representing a group of objects that share common properties and relationship.
a) Class
b) Structure
c) Array
d) None of these
Answer:
a) Class

Question 18.
……………….. are the basic unit of OOP.
a) Attributes
b) Objects
c) Members
d) None of these
Answer:
b) Objects

Samacheer Kalvi 11th Computer Science Guide Chapter 13 Introduction to Object-Oriented Programming Techniques

Question 19.
The class variables are called……………………
a) Instances
b) Objects
c) Either A or B
d) None of these
Answer:
c) Either A or B

Question 20.
An identifiable entity with some characteristics and behaviour is called ………………
a) Instances
b) Objects
c) Either A or B
d) None of these
Answer:
c) Either A or B

Question 21.
In ……………… method, programs are designed around the data being operated.
a) Modular Programming
b) Procedural Programming
c) Object-Oriented Programming
d) All the above
Answer:
c) Object-Oriented Programming

Samacheer Kalvi 11th Computer Science Guide Chapter 13 Introduction to Object-Oriented Programming Techniques

Question 22.
………………… language is based on object-oriented programming.
a) C++, Java
b) VB.Net
c) Python
d) All the above
Answer:
d) All the above

Question 23.
……………… is widely accepted that object-oriented programming is the most important and powerful way of creating software.
a) Modular Programming
b) Procedural Programming
c) Object-Oriented Programming
d) All the above
Answer:
c) Object-Oriented Programming

Question 24.
The Object-Oriented Programming approach mainly encourage ______
a) Modularisation
b) Software re-use
c) Both A and B
d) None of these
Answer:
c) Both A and B

Samacheer Kalvi 11th Computer Science Guide Chapter 13 Introduction to Object-Oriented Programming Techniques

Question 25.
…………………….. means the program can be decomposed into modules.
a) Modularisation
b) Software re-use
c) Both A and B
d) None of these
Answer:
a) Modularisation

Question 26.
………………… means, a program can be composed of existing and new modules.
a) Modularisation
b) Software re-use
c) Both A and B
d) None of these
Answer:
b) Software re-use

Samacheer Kalvi 11th Computer Science Guide Chapter 13 Introduction to Object-Oriented Programming Techniques

Question 27.
The main feature of Object-Oriented Programming is ………………….
a) Data Abstraction and Encapsulation
b) Modularity
c) Inheritance and Polymorphism
d) All the above
Answer:
d) All the above

Question 28.
……………………. implements abstraction.
a) Polymorphism
b) Encapsulation
c) Abstraction
d) Inheritance
Answer:
b) Encapsulation

Question 29.
……………….. can be called data binding.
a) Polymorphism
b) Encapsulation
c) Abstraction
d) Inheritance
Answer:
b) Encapsulation

Samacheer Kalvi 11th Computer Science Guide Chapter 13 Introduction to Object-Oriented Programming Techniques

Question 30.
……………………… is the most striking feature of a class,
a) Polymorphism
b) Encapsulation
c) Abstraction
d) Inheritance
Answer:
b) Encapsulation

Question 31.
The encapsulation of data from direct access by the program is called …………………….
a) Data hiding
b) Information hiding
c) Either A or B
d) None of these
Answer:
c) Either A or B

Question 32.
…………………… refers to showing only the essential features without revealing background details,
a) Polymorphism
b) Encapsulation
c) Abstraction
d) Inheritance
Answer:
c) Abstraction

Samacheer Kalvi 11th Computer Science Guide Chapter 13 Introduction to Object-Oriented Programming Techniques

Question 33.
The attributes are called ……………………..
a) Data members
b) Methods
c) Member functions
d) Either B or C
Answer:
a) Data members

Question 34.
…………………….. hold information.
a) Data members
b) Methods
c) Member functions
d) Either B or C
Answer:
a) Data members

Question 35.
The functions that operate on data numbers are called …………………..
a) Data members
b) Methods
c) Member functions
d) Either B or C
Answer:
d) Either B or C

Samacheer Kalvi 11th Computer Science Guide Chapter 13 Introduction to Object-Oriented Programming Techniques

Question 36.
………………. is designing a system that is divided into a set of functional units.
a) Polymorphism
b) Modularity
c) Abstraction
d) Inheritance
Answer:
b) Modularity

Question 37.
……………………. is the technique of building new classes from an existing class,
a) Polymorphism
b) Modularity
c) Abstraction
d) Inheritance
Answer:
d) Inheritance

Question 38.
In inheritance, the existing class is called as …………………….. class.
a) Base
b) Derived
c) Abstract
d) None of these
Answer:
a) Base

Samacheer Kalvi 11th Computer Science Guide Chapter 13 Introduction to Object-Oriented Programming Techniques

Question 39.
In inheritance, the newly created class is called as ………………… class.
a) Base
b) Derived
c) Abstract
d) None of these
Answer:
b) Derived

Question 40.
……………… is the ability of a message or function to be displayed in more than one form.
a) Polymorphism
b) Modularity
c) Abstraction
d) Inheritance
Answer:
a) Polymorphism

Question 41.
……………. means, write once and use it multiple times.
a) Re-usability
b) Redundancy
c) Security
d) None of these
Answer:
a) Re-usability

Samacheer Kalvi 11th Computer Science Guide Chapter 13 Introduction to Object-Oriented Programming Techniques

Question 42.
If we need the same functionality in multiple class you will write a common class for the same functionality and inherit that class to subclass is called ……………………
a) Re-usability
b) Redundancy
c) Security
d) None of these
Answer:
b) Redundancy

Question 43.
………………. is a good feature for data redundancy.
a) Polymorphism
b) Modularity
c) Abstraction
d) Inheritance
Answer:
d) Inheritance

Question 44.
…………………… programs are much larger than other programs.
a) Modular
b) Procedural
c) Object-Oriented
d) All the above
Answer:
c) Object-Oriented

Samacheer Kalvi 11th Computer Science Guide Chapter 13 Introduction to Object-Oriented Programming Techniques

Question 45.
………………….. program requires a lot of work to create.
a) Modular
b) Procedural
c) Object-Oriented
d) All the above
Answer:
c) Object-Oriented

Question 46.
……………… programs .are slower than other programs, because of their size.
a) Modular
b) Procedural
c) Object-Oriented
d) All the above
Answer:
c) Object-Oriented

Samacheer Kalvi 11th Computer Science Guide Chapter 13 Introduction to Object-Oriented Programming Techniques

Very Short Answers 2 Marks

Question 1.
Write a note on an object-oriented program.
Answer:
Object-Oriented Programming (OOP) is the term used to describe a programming approach based on classes and objects. The object-oriented paradigm allows us to organize software as a collection of objects that consist of both data and behaviour.

Question 2.
What is modularity?
Answer:
Modularity is designing a system that is divided into a set of functional units (named modules) that can be composed into a larger application.

Question 3.
Define Data binding.
Answer:
Encapsulation is about binding the data variables and functions together in class. It can also be called data binding.

Samacheer Kalvi 11th Computer Science Guide Chapter 13 Introduction to Object-Oriented Programming Techniques

Short Answers (3 Marks)

Question 1.
Write about objects.
Answer:
Objects: Represents data and its associated function together into a single unit. Objects are the basic unit of OOP. Basically, an object is created from a class. They are instances of class also called class variables. An identifiable entity with some characteristics and behaviour is called an object.

Question 2.
What are Encapsulation and data binding?
Answer:
The mechanism by which the data and functions are bound together into a single unit is known as Encapsulation. Encapsulation is the most striking feature of a class. The data is not accessible to the outside world, and only those functions which are wrapped in the class can access it. These functions provide the interface between the object’s data and the program. This encapsulation of data from direct access by the program is called data hiding or information hiding.

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Tamilnadu State Board New Syllabus Samacheer Kalvi 11th Computer Science Guide Pdf Chapter 12 Arrays and Structures Text Book Back Questions and Answers, Notes.

Tamilnadu Samacheer Kalvi 11th Computer Science Solutions Chapter 12 Arrays and Structures

11th Computer Science Guide Arrays and Structures Text Book Questions and Answers

Book Evaluation

Part I

Choose The Correct Answer

Question 1.
which of the following is the collection of variables of the same type that are referenced by a common name ?
a) int
b) float
c) Array
d) class
Answer:
c) Array

Question 2.
Array subscripts is always starts with which number ?
a) -1
b) 0
c) 2
d) 3
Answer:
b) 0

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 3.
int age[ ]={6,90,20,18,2}; How many elements are there in this array?
a) 2
b) 5
c) 6
d) 4
Answer:
b) 5

Question 4.
cin>>n[3]; To which element does this statement accepts the value?
a) 2
b) 3
c) 4
d) 5
Answer:
c) 4

Question 5.
By default, the string end with which character?
a) \0
b) \t
c) \n
d) \b
Answer:
a) \0

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Part – II

Very Short Answers

Question 1.
What is Traversal in an Array?
Answer:
Accessing each element of an array at least once to perform any operation is known as “Traversal”. Displaying all the elements in an array is an example of “traversal”.

Question 2.
What is Strings?
Answer:
A string is defined as a sequence of characters where each character may be a letter,’ number or a symbol.
Every string is terminated by a null (\0) character which must be. appended at the end of the string.

Question 3.
What is the syntax to declare two – dimensional array? ‘
Answer:
The declaration of a 2-D array is
datatype array_name[row – size] [col – size];
In the above declaration, data-type refers to any valid C++ data – type, array _ name refers to the name of the 2 – D array, row – size refers to the number of rows and col-size refers to the number of columns in the 2 – D array.

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Part – III

Short Answers

Question 1.
Define an Array. What are the types?
Answer:
An array is a collection of variables of the same type that are referenced by a common name.
There are different types of arrays used in C++. They are:

  • One-dimensional arrays
  • Two-dimensional arrays
  • Multi-dimensional arrays

Question 2.
With note an Array of strings.
Answer:
An array of strings is a two – dimensional character array. The size of the first Index (rows) denotes the number of strings and the size of the second index (columns) denotes the maximum length of each string. Usually, an array of strings are declared in such a way to accommodate the null character at the end of each string. For example, the 2-D array has the declaration:
char name [7][10];
In the above declaration,
No. of rows = 7;
No. of columns = 10;
We can store 7 strings each with a maximum length of 10 characters.

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 3.
Write a C++ program to accept and print your name?
Answer:
PROGRAM
#include<iostream>
using namespace std;
int main( )
{
char str[100];
cout<< “Enter your name :”;
cin.get(str,100);
cout<< “You name is : ” << str <<endl;
return 0;
}
Output
Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures 1

Part – IV

Explain In Detail

Question 1.
write a c++ program to find the difference between two matrix.
Answer:
PROGRAM
#include<iostream>
#include<conio.h>
using namespace std;
int main( )
{
int row, col, m1[10][10], m2[10][10], sum[10][10];
cout<<“Enter the number of rows : “;
cin>>row;
cout<<“Enter the number of columns :”;
cin>>col;
cout<< “Enter the elements of first matrix: “<<endl;
for (int i = 0;i<row;i++ )
for (int j = 0;j <col;j++ )
cin>>m1[i][j];
cout< < “Enter the elements of second matrix: “<<endl;
for (int i = 0;i<row;i++ )
for (int j = 0;j<col;j++ )
< cin>>m2[i][j];
cout<<“Output: “<<endl;
for (int i = 0;i<row;i++ )
{
for (int j = 0;j<col;j++ )
{
sum[i][j]=m1[i][j] – m2[i][j]); cout<<sum[i][j]<<“”;
}
cout<<endl<<endl;
}
getch( );
return 0;
}
Output
Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures 2

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 2.
How will you pass two dimensional array to a function explain with example.
Answer:
Passing 2″D array to a function:
C++ program to display values from two dimensional array.
#include<iostream>
using namespace std;
void display (int n[3][2]);
int main( )
{
int num[3][2] = { {3, 4}, {9, 5>, {7, 1} } ;
display(num);
return 0;
}
void display(int n[3][2])
{
cout << “\n Displaying Values” << endl; for (int i=0; i<3; i++)
{
for (int j=0; j<2; j++)
{
cout << n[i][j] << “”;
}
cout << endl << endl;
}
}
Output
Displaying Values
3 4
9 5
7 1
In the above program, the two-dimensional array num is passed to the function display
( ) to produce the results.

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

11th Computer Science Guide Arrays and Structures Additional Questions and Answers

Choose The Correct Answer (1 Mark)

Question 1.
The size of the array is referred to as its ………………..
(a) dimension
(b) direction
(c) location
(d) space
Answer:
(a) dimension

Question 2.
…………… is an easy way of storing multiple values of the same type referenced by a common name.
a) Variables
b) Literals
c) Array
d) None of these
Answer:
c) Array

Question 3.
Displaying all the elements in an array is an example of ………………..
(a) memory allocation
(b) call by reference
(c) traversal
(d) none of these
Answer:
(c) traversal

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 4.
A (n) ………………….. is a collection of variables of the same type that are referenced by a common name.
a) Structures
b) Array
c) Unions
d) None of these
Answer:
b) Array

Question 5.
During ……………….. the array of elements cannot be initialized more than its size.
(a) declaration
(b) initialization
(c) assigning
(d) execution
Answer:
(b) initialization

Question 6.
The …………….. of the array is referred to as its dimension.
a) Elements
b) Size
c) Format
d) None of these
Answer:
b) Size

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 7.
Pass an array to a function in C++, the function needs the array name as ………………..
(a) a function
(b) an argument
(c) global object
(d) string
Answer:
(b) an argument

Question 8.
…………………. is a type of arrays used in C++.
a) One-dimensional array
b) Two-dimensional array
c) Multidimensional array
d) All the above
Answer:
d) All the above

Question 9.
A structure without a name tag is called ………………..
(a) homogenous structure
(b) anonymous structure
(c) array of structure
(d) dynamic memory
Answer:
(b) anonymous structure

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 10.
A one-dimensional array represents values that are stored in a single …………….
a) Row
b) Column
c) Either A or B
d) None of these
Answer:
c) Either A or B

Question 11.
Array size should be specified with …………………
a) square brackets[ ]
b) Parenthesis ( )
c) Curly braces{ }
d) Angle brackets < >
Answer:
a) square brackets[ ]

Question 12.
In an array declaration, ……………… defines how many elements the array will hold.
a) array_name
b) array_size
c) data_type
d) None of these
Answer:
b) array_size

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 13.
In an array declaration, …………………. declares the basic type of the array, which is the type of each element in the array.
a) array_name
b) array_size
c) data type
d) None of these
Answer:
c) data type

Question 14.
In an array declaration, ……………….. specifies the name with which the array will be referenced
a) array_name
b) array_size
c) data type
d) None of these
Answer:
a) array_name

Question 15.
The array subscript always starts with ………………
a) 0
b) 1
c) -1
d) None of these
Answer:
a) 0

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 16.
The subscript always is a(n) ………………value.
a) Integer
b) Unsigned integer
c) Signed integer
d) float
Answer:
b) Unsigned integer

Question 17.
In Turbo C++, int data type requires …………….. bytes of memory.
a) 4
b) 8
c) 2
d) 1
Answer:
c) 2

Question 18.
In Dev C++, int data type requires ………………. bytes of memory,
a) 4
b) 8
c) 2
d) 1
Answer:
a) 4

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 19.
The memory space allocated for an array can be calculated using the -formula.
a) Number of bytes allocated for the type of array + Number of elements
b) Number of bytes allocated for the type of array x Number of elements
c) Number of bytes allocated for the type of array – Number of elements
d) None of these
Answer:
b) Number of bytes allocated for the type of array x Number of elements

Question 20.
An array can be initialized at the time of its ………………
a) Declaration
b) Process
c) Either A or B
d) None of these
Answer:
a) Declaration

Question 21.
Unless an array is initialized, all the array elements contain ……………..values.
a) Null
b) Default
c) Garbage
d) None of these
Answer:
c) Garbage

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 22.
While declaring and Initializing values In an array, the values should be given within the ……………..
a) square brackets[ ]
b) Parenthesis ()
c) Curly braces{ }
d) Angle brackets < >
Answer:
c) Curly braces{ }

Question 23.
The …………….. of an array may be optional when the array is initialized during declaration.
a) Data type
b) Size
c) Name
d) None of these
Answer:
b) Size

Question 24.
The subscript in the bracket can be a(n) ……………….
a) Variable
b) Constant
c) Expression that evaluates to an integer
d) Either A or B or C
Answer:
d) Either A or B or C

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 25.
Accessing each element of an array at least once to perform any operation is known as ………………..
a) Traversal
b) Process
c) Reference
d) None of these
Answer:
a) Traversal

Question 26.
…………………. is a process of finding a particular value present in a given set of numbers.
a) Filtering
b) Searching
c) Seeking
d) None of these
Answer:
b) Searching

Question 27.
The ………………. compares each element of the list with the value that has to be searched until all the elements in the array have been traversed and compared.
a) Linear search
b) Sequential search
c) Either A or B
d) None of these
Answer:
c) Either A or B

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 28.
A ……………. is defined as a sequence of characters where each character may be a letter, number, or a symbol.
a) String
b) Character
c) Literal
d) Identifier
Answer:
a) String

Question 29.
In C++, there is no basic data type to represent a …………….
a) String
b) Character
c) Literal
d) float
Answer:
a) String

Question 30.
How much memory required for the following array?
char country[6];
a) 12 bytes
b) 6 bytes
c) 60 Bytes
d) 24 bytes
Answer:
b) 6 bytes

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 31.
…………….. is a way of initializing the character array:
a) char country[6]={T, ‘N’ ‘D’ ‘I’, ‘A’, ‘\0’};
b) char country[ ]=”INDIA”;
c) char country[ ]={T, ‘N’, ‘D’, T, ‘A’ ‘\0’};
d) Either A or B or C
Answer:
d) Either A or B or C

Question 32.
Which is a correct statement from the following?
a) At the end of the string, a null character is automatically added by the compiler.
b) If the size of the array is not explicitly mentioned, the compiler automatically calculates the size of the array based on the number of elements in the list and allocates space accordingly.
c) In the initialization of the string, if all the characters are not initialized, then the rest of the characters will be filled with NULL.
d) All the above
Answer:
d) All the above

Question 33.
In C++,………………. is used to read a line of text including blank spaces.
a) cin.get( )
b) cin
c) put( )
d) None of these
Answer:
a) cin.get( )

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 34.
………………. function can read the characters till it encounters a newline character or a delimiter specified by the user.
a) getline( )
b) put
c) puts( )
d) None of these
Answer:
a) getline( )

Question 35.
…………………. arrays are a collection of similar elements where the elements are stored in a certain number of rows and columns.
a) One dimensional
b) Two dimensional
c) Multidimensional
d) All the above
Answer:
b) Two dimensional

Question 36.
In two dimensional arrays, …………………. size is compulsory.
a) Column
b) Row
c) Both A and B
d) None of these
Answer:
a) Column

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 37.
In two dimensional arrays, …………….. size is optional.
a) Column
b) Row
c) Both A and B
d) None of these
Answer:
b) Row

Question 38.
int A[3][4 j; How many elements are there in the array “A”?
a) 3
b) 4
c) 7
d) 12
Answer:
d) 12

Question 39.
The two-dimensional array uses ………………. index values to access a particular element in it.
a) two
b) one
c) three
d) many
Answer:
a) two

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 40.
In a two dimensional array, the first index specifies the …………….. value.
a) Column
b) Row
c) Both A and B
d) None of these
Answer:
b) Row

Question 41.
In a two dimensional array, the second index specifies the …………… value.
a) Column
b) Row
c) Both A and B
d) None of these
Answer:
a) Column

Question 42.
The two-dimensional array can be viewed as a …………………
a) List
b) Matrix
c) Linear block
d) None of these
Answer:
b) Matrix

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 43.
There are …………… types of 2-D array memory representations.
a) two
b) one
c) three
d) many
Answer:
a) two

Question 44.
……………… is a type of 2-D array memory representation.
a) Row-Major order
b) Column-Major order
c) Either A or B
d) None of these
Answer:
c) Either A or B

Question 45.
In row-major order, all the elements are stored ……………… in contiguous memory locations.
a) Column by Column
b) Row by Row
c) Both A and B
d) None of these
Answer:
b) Row by Row

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 46.
In column-major order, all the elements are stored ………………. in contiguous memory locations.
a) Column by Column
b) Row by Row
c) Both A and B
d) None of these
Answer:
a) Column by Column

Question 47.
An array of strings is a ………………. dimensional character array,
a) Two
b) One
c) Multi
d) None of these
Answer:
a) Two

Question 48.
In a two-dimensional character array, the size of the first index (rows) denotes the ……………….
a) Maximum length of each string
b) Number of strings
c) Maximum characters
d) None of these
Answer:
b) Number of strings

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 49.
In a two-dimensional character array, the size of the second index (rows) denotes the ……………….
a) Maximum length of each string
b) Number of strings
c) Maximum characters
d) None of these
Answer:
a) Maximum length of each string

Question 50.
char Name[6][10]; How many strings can be stored in the above array?
a) 10
b) 60
c) 6
d) 16
Answer:
c) 6

Question 51.
To pass an array to a function in C++, the function needs the ………….. as an argument,
a) Array name
b) Array type
c) Dimension
d) None of these
Answer:
a) Array name

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Very Short Answers (2 Marks)

Question 1.
What is the formula to calculate the memory space allocated for an array?
Answer:
A number of bytes allocated for the type of array x Number of elements.

Question 2.
What are the types of arrays?
Answer:
There are different types of arrays used in C++. They are:

  1. One-dimensional arrays
  2. Two-dimensional arrays
  3. Multi-dimensional arrays

Question 3.
Write about returning structures from functions.
Answer:
A structure can be passed to a function through its object. Therefore, passing a structure to a function or passing a structure object to a function is the same because the structure object represents the structure. Like a normal variable, a structure variable(structure object) can be passed by value or by references/addresses. Similar to built-in data types, structures also can be returned from a function.

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 4.
Write the syntax and example for one-dimensional declaration and initialization.
Answer:
Syntax:
[size] = {value-1,value-2,………….,value-n};
Example:
Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures 3

Question 5.
What is a global object?
Answer:
Objects declared along with structure definition are called global objects.

Question 6.
Write a note on strings.
Answer:
strings:
A string is defined as a sequence of characters where each character may be a letter, number or symbol. Each element occupies one byte of memory. Every string is terminated by a null C\0′ ASCII code 0) character which must be appended at the end of the string.

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 7.
Differentiate array and structure.
Answer:
Array:

  • An array is a collection of variables of the same data type.
  • Array data are accessed using index.
  • Array allocates static memory
  • Array element access takes lesser time.

Structure:

  • A structure is a collection of variables of different data type.
  • Structure elements are accessed using operator.
  • Structures allocate dynamic memory.
  • Structure elements take more time.

Short Answers (3 Marks)

Question 1.
Write about the initialization of 2 – D array.
Answer:
The array can be initialized in more than one way at the time of 2-D array declaration.
For example
int matrix[4][3] = {
{10,20,30},// Initializes row 0
{40,50,60},// Initializes row 1
{70,80,90},// Initializes row 2
{100,110,120}// Initializes row 3
};
int matrix[4][3] = {10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120};
Array’s row size is optional but column size is compulsory.

Question 2.
What is subscript? Give its rules,
Answer:
subscript:
Each element has a unique index number starting from 0 which is known as a subscript.
Rules for subscript:

  • The subscript always starts with 0.
  • It should be an unsigned integer value.
  • Each element of an array is referred to by its name with a subscript index within the square bracket.

For example:
num[3] refers to the 4th element in the array.

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 3.
How memory locations are allocated to a one-dimensional array?
Answer:
Memory representation of a one-dimensional array:
The amount of storage required to hold an array is directly related to type and size.
The following figure shows the memory allocation of an array with five elements.
Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures 4
The above figure clearly shows that the array num is an integer array with 5 elements. Here, there is a total of 5 elements in the array, where for each element, 4 bytes in Dev C++ (or)2 bytes in Turbo C++ will be allocated. Totally 20 bytes will be allocated for this array (In Turbo C++ 10 Bytes).

Question 4.
Tabulate the memory requirement of data type in Turbo C++ and Dev C++.
Answer:

Data type

Turbo C++

Dev C++

char11
int24
float44
long44
double88
long double1010

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 5.
Explain character Array (String) creation with syntax and example.
Answer:
To create any kind of array, the size (length) of the array must be known in advance, so that the memory locations can be allocated according to the size of the array. Once an array is created, its length is fixed and cannot be changed during run time, This is shown in the following figure.
Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures 5
Syntax of array declaration is:
char array_name[size];
In the above declaration, the size of the array must be an unsigned integer value.

For example,
char country[6];
Here, the array reserves 6 bytes of memory, for storing’ a seqi characters. The length of the string cannot be more than 5 characters and one location is reserved for the null character at the end.

Question 6.
What is an array of strings?
Answer:
An array of strings is a two – dimensional character array. The size of the first index (rows) denotes the number of strings and the size of the second index (columns) denotes the maximum length of each string. Usually, an array of strings are declared in such a way to accommodate the null character at the end of each string. For example, the 2 – D array has the declaration: char Name[6][10];
In the above declaration, the 2 – D array has two indices which refer to the row size and column size, that is 6 refers to the number of rows, and 10 refers to the number of columns.

Question 7.
Write note on getline( ) function.
Answer:
In C++, getline( ) is also used to read a line . of text from the input stream. It can read the characters tilt it encounters a newline character or a delimiter specifier’ by the user. This function is available in the header.

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 8.
How memory represented for a 2-D array?
Answer:
There are two types of 2-D array memory representations. They are:

  • Row Major order
  • Column Major order

For example:
int A[4][3]={ { 8,6,5}, { 2,1,9}, {3,6,4}, {4,3,2} };
Row Major order:
In row-major order, all the elements are stored row by row in continuous memory locations, that is, ail the elements in first row, then in the second row and soon. The memory representation of row-major order is as shown below.
Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures 6

Question 9.
How 2-D character array initialized and stored in memory? Explain.
Answer:
2D char array initialization:

For example:
char Name[6][10] = {“Mr. Bean’; “Mr.Bush”
“Nicole”, “Kidman” “Arnold”, “Jodie”};
In the above’ example, the 2-D array is initialized with 6 strings, where the string is a maximum of 9 characters long since the last character is null. The memory arrangement of a 2-D array is shown below and ail the strings are stored in continuous locations.
Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures 7

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 10.
What is called nested structure? Give example.
Answer:
The structure declared within another structure is called a nested structure. Nested structures act as members of another structure and the members of the child structure can be accessed as parent structure name. Child structure name. Member name, struct dob
{
int date;
char month[3];
int year;
} ;
Values can be assigned to this structure as follows.
dob = {25, “DEC”, 2017}

Question 11.
Write a program to pass an array as an argument to a function.
Answer:
In C++, arrays can be passed to a function as an argument.
To pass an array to a function in C++, the function needs the array name as an argument.
C++ program-to display marks of 5 students (one-dimensional array)
#indude<iostream>
using namespace std;
void display (int m[5]);
int main( )
{
int marks[5]={88, 76, 90, 61, 69};
display(marks);
return 0;
}
void’ display (int m[5])
{
cout << “\n. Display Marks: ” << end!; for (int i=0; i<5; i++)
{
cout <-< “Student” << i+1 << ” << m[i]<<endl;
}
}
Output
Display Marks:
Student 1: 88
Student 2: 76
Student 3: 90
Student 4: 61
Student 5: 69

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 12.
Write a C++ program to pass a 2-D array to a function.
Answer:
C++ program to display values from two dimensional array:
#include<iostream>
using namespace std;
void display (int n[3][2]);
int main( )
{
int num[3][2] = { {3, 4}, (9, 5}, {7,1} };
display(num);
return 0; ‘
}
void display(int n[3][2])
{
cout << “\n Displaying Values” << endl;
for (int i=0; i<3; i++)
{
for (int j=0; j<2; j++)
{
cout << n[i][j] << ”
}
cout << endl << endl;
}
}
Output
Displaying Values
3 4
9 5
7 1

Question 13.
Write a user-defined function to return the structure after accepting value through the keyboard. The structure definition is as follows: struct Item{int item no; float price;};
Answer:
item accept (item i)
{

cout << “\n Enter the Item No:”; cin >> i.no;
cout << “\n Enter the Item Price:”; cin >> i.price;
return i;

}

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Explain in Detail (5 Marks)

Question 1.
How will you search an element in a one-dimensional array? Explain linear search.
Answer:
Searching in a one-dimensional array:
Searching is a process of finding a particular value present in a given set of numbers. The linear search or sequential search compares each element of the list with the value that has to be searched until all the elements in the array have been traversed and compared.

Program for Linear Search
#include<iostream>
using namespace std;
int Search(int arr[ ], int size, int value)
{
for (int i=0; <size; i++)
{
if (arr[i] == value)
return i; // return index value
}
return -1;
}
int main( )
{
int num[10], val, id;
for (int i=0; i< 10; i++) .
{
cout<<“\n Enter value” << i+1 <<“=”;
cin>>num[i];
}
cout<< “\n Enter a value to be searched: “;
cin>>val;
id=Search(num,10,val);
if(id==-1) .
cout<< “\n Given value is not found in the array..”;
else
cout<< “\n The value is found at the position” << id+1;
return 0;
}
The above program reads an array and prompts for the values to be searched. It calls the Search() function which receives array, size and value to be searched as parameters. If the value is found, then it returns the array index to the called statement; otherwise, it returns -1.

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 2.
Explain two-dimensional array with syntax and example.
Answer:
Two-dimensional array:
Two-dimensional (2D) arrays are collections of similar elements where the elements are stored in a certain number of rows and columns. An example m x n matrix where m denotes the number of rows and n denotes the number of columns is shown in the following figure, int arr[3][3];
2D array conceptual memory representation
Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures 8

The array arr can be conceptually viewed in matrix form with 3 rows and columns. point to be noted here is since the subscript starts with 0 arr [0][0] represents the first element.

The syntax for declaration of a 2-D array is:
data-type array_name[row-size][col-size];
In the above declaration, data-type refers to any valid C++ data-type, array_name refers to the name of the 2-D array, row-size refers to the number of rows and col-size refers to the number of columns in the 2-D array.

For example:
int A[3][4];
In the above example, A is a 2-D array, 3 denotes the number of rows and 4 denotes the number of columns. This array can hold a maximum of 12 elements.

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Case Study

Question (1)
Write a program to accept the marks of 10 students and find the average, maximum and minimum marks.
Answer:
PROGRAM
#include<iostream>
using namespace std;
int main( )
{
int marks[10], sum=0,max,min;
float avg;
cout<< “\n Enter Mark 1” << “=”;
cin>> marks[0];
max=marks[0];
min=marks[0];
for(int i=1; i< 10; i++)
{
cout<< “\n Enter Mark” << i+1 << “=”;
cin>> marks[i];
sum=sum+marks[i];
if (marks[i]>max)
max = marks[i];
if (marks[i]<min)
min = marks[i];
}
avg=sum/10.0;
cout<< “\n The Total Marks: ” << sum;
cout<< “\n The Average Mark: ” <<avg;
cout<< “\n The Maximum Mark: ” <<max;
cout<< “\n The Minimum Mark: ” <<min;
}
Output
Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures 9

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question (2)
Write a program to accept rainfall recorded in four metropolitan cities of India and find the city that has the highest and lowest rainfall.
Answer:
PROGRAM
#include<iostream>
#include<string.h>
using namespace std;
int main( )
{
int rate[10],min,n;
char shop[5][20];
char minshop[20];
cout<<“\nHow many Shops
cin>>n;
for(int i=0;i<n;i++)
{
cout<<“\nEnter Name of the Shop “<<i+1<<” :”;
cin> >shop[i];
cout<<“\nEnter price of Product-X at “<<shop[i]<<” :”;
cin>>rate[i];
}
min=rate[0];
strcpy(minshop,shop[0]);
for(int i=l;i<n;i++)
{
if (rate[i]<min)
{
min = rate[i];
strcpy(minshop,shop[i]);
}
}
cout< < “\n The Lowest cost of the Proudct=X at the” “<<minshop <<“is”<<min;
}
Output
Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures 10

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question (3)
Survey your neighboring shops and find the price of any particular product of interest and suggest where to buy the product at the lowest cost.
Answer:
PROGRAM
#include<iostream>
#include<string.h>
using namespace std;
int main( )
{
int rate[10],min,n;
char shop[5][20];
char minshop[20];
cout<<“\nHow many Shops “;
cin>>n;
for(int i=0;i<n;i++)
{
cout<<“\nEnter Name of the Shop “<<i+l<<” :”;
cin>>shop[i];
cout<<“\nEnter price of Product-X at “<<shop[i]<<“:”;
cin> >rate[i];
}
min=rate[0];
strcpy(nninshop,shop[0]);
for(int i=l;i<n;i++)
{
if (rate[i]<min)
{
min = rate[i];
strcpy(minshop,shop[i]);
}
}
cout< < “\n The Lowest cost of the Proudct=X at the ” <<minshop <<“is”<<min;
}
Output
Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures 11

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

STRUCTURES

Book Evaluation

Part -I

Choose The Correct Answer

Question 1.
The data elements in the structure are also known as ……………..
a) objects
b) members
c) data
d) records
Answer:
b) members

Question 2.
Structure definition is terminated by ……………..
a) :
b) }
c) ;
d) ::
Answer:
c) ;

Question 3.
What will happen when the structure is declared?
a) it will not allocate any memory
b) it will allocate the memory
c) it will be declared and initialized
d) it will be only declared
Answer:
b) it will allocate the memory

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 4.
What is the out of this program?
#include<iostream>
#include<string.h>
using namespace std;
int main( )
{
struct student
{
int n;
char name[10];
};
students;
s.n = 123;
183
strcpy(s.name, “Balu”);
cout<<s.n;
co
ut<< s.name <<endl;
return 0;
}
a) 123Balu
b) BaluBalu
c) Balul23
d) 123 Balu
Answer:
a) 123Balu

Question 5.
A structure declaration is given below.
struct Time
{
int hours;
int minutes;
int seconds;
}t;
Using the above declaration which of the following refers to seconds.
a) Time.seconds
b) Time::seconds
c) seconds
d) t. seconds
Answer:
d) t. seconds

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 6.
What will be the output of this program?
#include <iostream>
using namespace std;
struct ShoeType
{
string name; double price;
>; , ‘ ‘
int main()
184 {
ShoeType shoe1, shoe2;
shoe1.name = “Adidas”;
shoe1.price = 9.99;
cout<< shoe1.name<< ” #. “<< shoe1.
price<<endl;
shoe2 = shoe1;
shoe2.price = shoe2.price / 9;
cout<< shoe2.name<< ” # “<< shoe2.price;
return 0;

a) Adidas # 9.99 Adidas #1.11b) Adidas # 9.99 Adidas # 9.11
c) Adidas # 9.99 Adidas # 11.11d) Adidas #9.11 Adidas # 11.11

Answer:
a) Adidas # 9.99 Adidas #1.11

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 7.
Which of the following is a properly defined structure?
a) struct {int num;}
b) struct sum {int num;}
c) struct sum int sum;
d) struct sum {int num;};
Answer:
d) struct sum {int num;};

Question 8.
A structure declaration is given below.
struct employee
{
int empno;
char ename[10];
} e[5];
Using the above declaration which of the following statement is correct.
a) cout<<e[0].empno<<e[0].ename;
b) cout<<e[0].empno<<ename;
c) cout< <e[0]->empno< <e[0]->ename;
d) cout<<e.empno<<e.ename;
Answer:
a) cout<<e[0].empno<<e[0].ename;

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 9.
Which of the following cannot be a structure member?
a) Another structure
b) Function
c) Array
d) variable of double datatype
Answer:
b) Function

Question 10.
When accessing a structure member, the identifier to the left of the dot operator is the name of
a) structure variable
b) structure tag
c) structure member
d) structure-function
Answer:
a) structure variable

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Part – II

Very Short Answers

Question 1.
Define structure. What is its use?
Answer:
Definition:
The structure is user-defined which has the combination of data items with different data types. This allows to a group of variables of mixed data types together into a single unit.
Use: The structure provides a facility to store different data types as a part of the same logical element in one memory chunk adjacent to each other.

Question 2.
To store 100 integer numbers which of the following is good to use?
Answer:
Array or Structure State the reason.
In any situation when more than one variable is required to represent objects of uniform data types, an array can be used. If the elements are of different data types, then the array cannot support them.
The structure provides a facility to store different data types as a part of the same logical element in one memory chunk adjacent to each other. So, to store 100 integer numbers Array is good.

Question 3.
What is the error in the following structure definition.
Answer:
struct employee {inteno; charename[20]; char dept;}
Employee e1,e2;

Error:
In the above code objects for employee strcture is created at the end of structure definition. So,structure name is not needed. It may written as:
struct employee
{
int eno;
char ename[20];
char dept;
}e1,e2;

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 4.
Write a structure definition for the structure student containing exam no, name and an array for storing five subject marks.
Answer:
Structure definition:
struct student
{
int examno;
char sname[30];
int mark [5];
};

Question 5.
Why for passing a structure to a function call by reference is advisable to us?
Answer:
In call by reference, any change made to the contents of structure variable inside the function are reflected back to the calling function. Otherwise changes in the structure content within the function will not implement in the structure content.

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 6.
What is the size of the following highlighted variable in terms of byte if it is compiled in dev C++
Answer:
struct A{ float f[3]; char ch[5];long double d;>;
struct B{ A a; int arr[2][3];}b[3]
struct A {float f[3]; char ch[5]; long double d;>;
Memory requirements (Using Dev C++):

Variable

Memory requirement

float f(3);12 Bytes
char ch[5];   ,5 Bytes
double d;8 Bytes

Using Turbo C++ also the same memory is needed. (Only int data type requirement is differ. Here no int members. So, no change in the requirement.)
struct B { A a; int arr[2][3];}b[3];
Memory requirements (Using Dev C++):

Variable

Memory requirement

A a; (Which is a structure variable)25 Bytes
int arr[2][3];24 Bytes
b[3] which is a structure variable of structure B49 Bytes for each element of b. So, Total requirement of b[3] is 147 Bytes.

Memory requirements (Using Turbo C++):

Variable

Memory requirement

A a; (Which is a structure variable)25 Bytes
int arr[2][3];12 Bytes
b[3] which is a structure variable of structure B37 Bytes for each element of b. So, Total requirement of b[3] is 111 Bytes.

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 7.
Is the following snippet is fully correct. If not identify the error.
Answer:
struct sum1{ int n1,n2;}s1;
struct sum2{int n1,n2}s2;
cin>>s1.n1>>s1.n2;
s2=s1;
No. It is not fully correct. The following errors are there.
Errors:

Statement

Error

struct sum1 {int n1,n2;}sl;No Error
struct sum2 {int n1,n2}s2;Semicolon missing at the end of declaration statement;
cin>>s1.n1>>s1. n2;No Error
s2-s1;Objects of different structures can not be directly copied.

Question 8.
Differentiate array and structure.
Answer:
In any situation when more than one variable is required to represent objects of uniform data¬types, array can be used. If the elements are of different data types, then array cannot support. If more than one variable is used, they can be stored in memory but not in adjacent locations. It increases the time consumption while searching.

The structure provides a facility to store different data types as a part of the same logical element in one memory chunk adjacent to each other.

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 9.
What are the different ways to initialize the structure members?
Answer:
Values can be assigned to structure elements similar to assigning values to variables.
Example:
Consider the following structure: struct Student
{
long int rollno;
int age;
float weight;
}
balu ;
We can initialize as given below:
balu.rollno= 702016;
balu. age=18; ‘
balu.weight= 48.5;
Also, values can be assigned directly as similar to assigning values to Arrays.
balu={702016, 18, 48.5};

Question 10.
What is wrong with the following C++ declarations?
Answer:
A. struct point ( double x, y)
B. struct point { double x, double y >;
C. struct point { double x; double y >
D. struct point { double x; double y; };
E. struct point { double x; double y; >

Errors:
A. struct point (double x, y)
Structure definition must be terminated with;. It is missing. Members must be enclosed in { }. So it may be written as
struct point { double x, y };

B. struct point {double x, double y>;
Structure member declaration must be terminated with; It is missing. So, it may corrected as
struct point {double x; double y;>; or struct point {double x, y;>;

C. struct point {double x; double y>
Structure member declaration and definition must be terminated with ; It is missing. So, it may corrected as
struct point {double x; double y;>; or
struct point { double x, y; >;

D. struct point {double x; double y;};,
No error .
E. struct point {double x; double y;>
– Structure definition must be terminated with ; it is missing. So, it may be corrected as
struct point {double x; double y;>;

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Part – III

Short Answers

Question 1.
How will you pass a structure to a function ?
Answer:
A structure variable can be passed to a function in a similar way of passing any argument that is of built-in data type,

  1. If the structure itself is an argument, then it is called “call by value”.
  2. If the reference of the structure is passed as an argument then it is called, “call by reference”.

Call by value
When a structure is passed as argument to a function using call by value method,any change made to the contents of the structure variable inside the function to which it is passed do not affect the structure variable used as an argument.

Call by reference
In this method of passing the structures to functions, the address of a structure variable / object is passed to the function using address of(&) operator. So any change made to the contents of structure variable inside the function are reflected back to the calling function.

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 2.
The following code sums up the total of all students name starting with ‘S’ and display it. Fill in the blanks with required statements.
Answer:
struct student {int exam no, lang, eng, phy, che, mat, esc, total; char name[15];>;
int main( )
{
student s[20];
for(int i=0;i<20;i++)
{
…………………. //accept student details
}
for(int i=0;i<20;i++)
{
……………. //check for name starts with’ letter “S”
…………….. // display the detail of the checked name
}
return 0;
}
MODIFIED PROGRAM
using namespace std;
#include<iostream>
struct student
{
int exam_.no,lang,eng,phy,che,mat,esc,total; char name[15];
};
int main( )
{
student s[20];
for(int i=0;i<20;i++)
{
//accept student details
cout<<“\nEnter student name”;
cin>>s[i].name;
cout<<“\nEnter student exam number”;
cin>>s[i].exam_no;
cout<<“\nEnter Languge Mark”;
cin>>s[i].lang;
cout<<“\nEnter Engjish Mark”;
cin>>s[i].eng;
cout<<“\nEnter Physics Mark”;
cin>>s[i].phy;
cout<<“\nEnter Chemistry Mark”;
cin>>s[i].che;
cout<<“\nEnter Maths Mark”;
cin>>s[i].mat;
cout<<“\nEnter Computer Science Mark”;
cin>>s[i].csc;
s[i].total = s[i].lang + s[i].eng + s[i]. phy+s[i].che+s[i].mat+s[i]. csc;
}
cout<<“\nDetails of student name starts with letter S “<<endl;
for(int i=0;i<20;i++)
{
//check for name starts with letter “S” if(s[i].name[0] == ‘S’)
{
// display the detail of the checked name

cout<<“\nName : “<<s[i].
name<<“Total Mark”<<s[i].
total <<endl;
}
}
return 0;
}
Output
Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures 12

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 3.
What is called nested structure. Give example
Answer:
The structure declared- within another structure is called a nested structure.
Example:
struct Student
{
int age;
float height, weight;
struct dob
{
int date;
char month[4];
int year;
};
}mahesh;
The nested structures act as members of another structure and the members of the child structure can be accessed as parent structure name. Child structure name. Member name.
Example:
mahesh. dob. date
Here

  • mahesh is a parent structure name.
  • dob is a child structure name
  • date is a member of child structure

Question 4.
Rewrite the following program after removing the syntactical error(s), if any.
Answer:
Underline each correction.
struct movie
{
charm_name[10];
charm-Lang[10];
float ticket cost =50;};
Movie;
void main( )
{
gets(m_name);
cin>>m-lang;
return 0; ,
}
MODIFIED PROGRAM
PROGRAM (USING DEV C++)
#include<iostream>
#include<conio.h>
#include<stdio.h>
struct movie
{
char m_name[10];
char m_lang[10];
float ticket_cost;
} Movie;
int main( )
{
std::cout<<“\nEnter Move! Name ;
gets(Movie.m_name);
std::cout<<:”\nEnter Movie Language ,:
std: :cin>>Movie.m -lang;
std::cout<<“\nEnter Ticket Cost: “;
std::cin>>Movie.ticket_cost;
std::cout<<“\nMovie name is : “<
std::cout< <“\nMovie Language is : “<<Movie.m-lang;
std::cout<<“\nTicket cost is : “<<Movie.ticket_cost;
}
Output
Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures 13

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 5.
What ¡s the difference among the following two programs?
a) #include<iostream.h>
struct point
{
double x;
double y;
};
int main()
{
struct point test;
testx = .25; test.y = .75;
cout< <test.x< ctest.y;
return 0;
}
b) #include
struct .
{
double x;
double y;
} Point;
int main(void)
{
Point test={.25,.75>;
return 0;
}
Answer:
The method of structure initialisation is different.

Question 6.
How to access members of a structure? Give f example.
Answer:
Once the two objects of student structure type are declared, their members can be accessed directly. The syntax for that is using a dot (.) between the object name and the member name.
Syntax is :
Object name. Member

For example:
struct Student
{
longrollno;
int age;
float weight;
}balu, frank;
The elements of the structure Student can be accessed as follows: balu.rollno balu.age balu. weight frank, rollno frank.age frank.weight
balu.rollno
balu.age
balu.weight
frank.rollno
frank.age
frank.weight

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 7.
Write the syntax and an example for structure.
Answer:
Structure is declared using the keyword ‘struct’. The syntax of creating a structure is given below.
struct structure_name
{
type member_name1;
type member_name2;
} reference_name;
An optional field reference_name can be used to declare objects of the structure type directly.

Example:
struct Student
{
longrollno;
int age;
float weight;
}balu, frank;

Question 8.
For the following structure, definition writes the user-defined function to accept data through the keyboard.
struct date
{
int dd,mm,yy
};
struct item
{
int item id;
char name[10];
float price;
date date_manif;
}
Answer:
USER DEFINED FUNCTION
item accept( )
{
item obj;
cout<<“\n Enter Item Id “;
cin> > obj. item id;
cout<<“\nEnter Name “;
cin>obj.name;
cout<<“\nEnter Price “;
cin>>obj.price;
cout<<“\nEnter Date: date, month and year
cin>>obj.date_manif.dd >> obj.date_manif. mm >> obj.date_manif.yy;
return(obj);
}

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 9.
What is called an anonymous structure? Give an example.
Answer:
A structure without a name/tag is called anonymous structure, struct
{
long rollno;
int age;
float weight;
} student;
The student can be referred to as a reference name to the above structure and the elements can be accessed like
student, roll no
student.age and
student.weight.

Question 10.
Write a user-defined function to return the structure after accepting value through the keyboard. The structure definition is as follows:
struct Item{int item no;float price;};
Answer:
USER DEFINED FUNCTION
Item accept( )
{
Item obj; ,
cout<<‘AnEnter Item Number and Price “; cin>>obj.item_no>>obj, price.
return(obj);
}

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Part-IV

Explain in Detail

Question 1.
Explain the array of structures with examples.
Answer:
A class may contain many students. So, the definition of structure for one student can also be extended to all the students. If the class has 20 students, then 20 individual structures are required. For this purpose, an array of structures can be used.
An array of structures is declared in the same way as declaring an array with built-in data types like int or char.
The following program reads the details of 20 students and prints the same.
#include<iostream>
using namespace std;
struct Student
{
int age;
float height, weight;
char name[30];
};
void main()
{
Student std[20];
int i;
cout<< ” Enter the details for 20 students”<<endl;
for(i=0;i<20;i++)
{
cout<< ” Enter the details of student”<<i+1<<endl;
cout<< ” Enter the age:”<<endl; cin>>std[i].age;
cout<< “Enter the height:”<<endl; cin>>std[i].height;
cout<< “Enter the weight:”<<endl; cin>>std[i].weight;
}
cout<< “The values entered for Age, height and weight are”<<endl;
for(i=0;i<20;i++)
cout<< “Student “<<i+l<< “\t”< <std[i]. age<< “\t”<<std[i].height<< “\t”<<std[i]. weight;
}
Output
Enter the details of 20 students
Enter the details for student1
Enter the age:
18
Enter the height:
160.5
Enter the weight:
46.5
Enter the details for student2
Enter the age:
18
Enter the height:
164.5
Enter the weight:
61.5
………………………………….
…………………………
The values entered for Age, height and weight are
Student 1 18 160.5 46.5
Student 2 18 164.5 61.5
………………………

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 2.
Explain call by value with respect to structure.
Answer:
A structure variable can be passed to a function in a similar way of passing any argument that is of built-in data type. If the structure itself is an argument, then it is called “call by value”.

Call by value
When a structure is passed as argument to a function using call by value method,any change made to the contents of the structure variable inside the function to which it is passed do not affect the structure variable used as an argument.
Example:
#include<iostream>
using namespace std;
struct Employee
{
char name[50]; ,
int age;
float salary;
};
void printData(Employee); // Function declaration
int main( )
{
Employee p;
cout<< “Enter Full name: “;
cin>>p.name;
cout<< “Enter age: “;
cin>>p.age;
cout<< “Enter salary: “;
cin>>p.salary;
// Function call with structure variable as an argument
printData(p);
return 0;
}
void printData(Employee q)
{
cout<< “\nDisplaying Information.” <<endl;
cout<< “Name: ” << q.name <<endl;
cout<<“Age: ” <<q.age<<endl;
cout<< “Salary:” <<q.salary;
}
Output
Enter Full name: Kumar
Enter age: 55
Enter salary: 34233.4
Displaying Information.
Name: Kumar
Age: 55
Salary: 34233.4
In the above example, a structure named Employee is declared and used. The values that are entered into the structure are name, age and salary of a Employee are displayed using a function named printData( ).

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 3.
How call by reference is used to pass structure to a function .Give an Example
Answer:
Call by reference
In this method of passing the structures to functions ,the address of a structure variable / object is passed to the function using address of(&) operator. So any change made to the contents of structure variable inside the function are reflected back to the calling function
Example:
#include<iostream>
using namespace std;
struct Employee
{
char name[50];
int age;
float salary;
};
void readData(Employee &);
void printData(Employee);
int main()
{
Employee p;
readData(p);
printData(p);
return 0;
}
void readData(Employee &p)
{
cout<< “Enter Full name: “;
cin.get(p.name, 50);
cout<< “Enter age:
cin>>p.age; ,
cout<< “Enter salary:
cin>>p. salary;
}
void printData(Employee p)
{
cout<< “\nDisplaying Information.” <<endl;
cout<< “Name: ” << p.name <<endl;
cout<<“Age:” <<p.age<<endl;
cout<< “Salary:” <<p.salary;
}
Output
Enter Full name: Kumar
Enter age: 55
Enter salary: 34233.4
Displaying Information.
Name: Kumar
Age: 55
Salary: 34233.4
Structures are usually passed by reference method because it saves the memory space and executes faster.

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 4.
Write a C++ program to add two distances using the following structure definition
Answer:
struct Distance
{
int feet;
float inch;
}d1, d2, sum;
PROGRAM
#include<iostream>
using namespace std;
struct Distance
{
int feet;
float inch;
} d1, d2, sum;
int main( )
{
cout<<“\nEnter distance 1: feet and inch : “;
cin>>d1.feet>>d1.inch;
cout<<“\nEnter distance 2: feet and inch :
cin>>d2.feet>>d2.inch;
sum.feet = d1.feet + d2.feet;
sum.inch =(d1.inch + d2.inch) – (int) (d1.inch + d2,inch) / 12 * 12;
sum.feet = sum.feet + (d1.inch + d2.inch)/12;
cout<<“\nDitance 1: Feet = “<<d1.feet<<”
Inch = “<<d1.inch;
cout<<“\nDitance 2: Feet = “<<d2.feet<<”
Inch = “<<d2.inch;
cout<<“\nSum of Distance 1 and 2 : Feet = “<<sum.feet<<” Inch = “<<sum.inch;
}
Output
Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures 14

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 5.
Write a C++ Program to Add two Complex Numbers by Passing Structure to a Function for the following structure definition
Answer:
struct complex
{
float real;
float imag;
};
The prototype of the function is complex add Complex Numbers(complex, complex);
PROGRAM
#include<iostream>
using namespace std;
struct complex
{
float real;
float imag;
};
complex add Complex Numbers (complex obj1,complex obj2)
{
complex obj3;
obj3.real = obj1.reai+obj2,real;
obj3.imag = obj1.imag + obj2.imag;
return(obj3);
}
int main( )
{
complex c1,c2,c3;
cout<<“\nEnter First complex number real and imaginary :”;
cin>>c1,real>>c1.imag;
cout<<“\nEnter Second complex number real and imaginary :”;
cin>>c2.real>>c2.imag;
c3 = addComplexNumbers(c1,c2);
cout<<“\nFirst Complex Number is : “< }
Output
Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures 15

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 6.
WrIte a C++ Program to declare a structure book containing name and author as character array of 20 elements each and price as Integer. Declare an array of book. Accept the name, author, price detail for each book. Define a user defined function to display the book details and calculate the total price. Return total price to the calling function.
Answer:
PROGRAM
using namespace std;
#include<iostream>
#include<iomanip>
#include<istdio.h>
struct book
{
char bname[20],author[20];
int price;
};
int display(book x[5])
{
int total;
for(int i=0;i<5;i++)
{
total = total + x[i].price;
cout<<“\nBook name : “<<x[i].
bname;
cout<<“\nAuthor name : “<<x[i].
author;
cout<<“\nPrice of the book: “<<x[i].
price;
}
return(total);C++C
}
int main( )
{
book. b[5];
for(int i=0;i<5;i++)
{
cout<<“\nEnter Book name “;
cin>>b[i].bname;
cout<<“\nEnter Author name “;
cin>>b[i].author;
cout<<“\nEnter Book Price “;
cin > > b[i]. price;
}
cout<<“\nDetails of Books”<<endl;
cout<<“\nTotal cost of the book is : Rs.”<<display(b);
}
Output
Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures 16

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 7.
Write a C++ program to declare and accept an array of professors. Display the details of the department=”COMP.SCI” and the name of the professors start with ‘A’. The structure “college” should contain the following members.
prof-id as integer ,
name and Department as character array
Answer:
PROGRAM
using namespace std;
#include<iostream>
#include<iomanip>
#include<string.h>
struct college .
{
char pname[20],department[20]; int prof-id;
};
void display(college x[5])
{
for(int i=0;i<5;i++)
{
if((strcmp(x[i]. department,”COMP. SCI”)==0) && x[i].pname[0]==’A’)
cout<<x[i].pname«endl;
}
return;
}
int main( )
{
college c[5];
for(int i=0;i <5;i++)
{
cout<<“\nEnter Professor Name “;
cin>>c[i].pname; ,
cout<<“\nEnter Department Name “;
cin> >c[i] .department;
cout< <“\nEnter Professor Id
cin>>c[i].prof-id;
}
cout<<“\nDetails of Comp. Sci. . Dept, Professors whose name starts. with A “<<endl; . display(c);
}
Output
Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures 17

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 8.
Write the output of the following C++ program
Answer:
#incluçle<iostream>
#include<stdio>
#include<string>
#include<conio>
using namespace std;
struct books
{
char name[20), author[20];
} a[50];
int main ( )
{
clrscr( );
cout<< “Details of Book No ” << 1 << “\n”;
cout<< “———————\n”;
cout<< ‘Book Name :”<<strcpy(a[0].
name,”Programming “)<<endl;
cout<< “Book Author :”<<strcpy(a[0].
author,”Dromy”)<<endl;
cout<< “\nDetails of Book No ” << 2 <<”\n”;
cout<< ” ——————- \n”;
cout<<- “Book Name :”<<strcpy(a[l].
name,”C++programming” )<<endl;
cout<< “Book Author :”<<strcpy(a[l].
author,”BjarneStroustrup “)< <endl;
cout<<“\n\n”;
cout<< “======================
============================
\n”; ‘
cout<< ” S.No\t| Book Name\t|author\n”;
cout<< “=======================
=============================
for (int i = 0; i < 2; i++)
{
cout<< “\n ” << i + 1 << “\t|” << a[i].name << “\t| ” << a[i],author;
}
cout<< “\n=========-==========
===========================
==”;
return 0;
}
Output
Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures 18

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 9.
Write the output of the following C++ program
Answer:
#include<iostream>
#include<string>
using namespace std;
struct student
{
introll_no;
char name[10];
long phone_number;
};
int main() .
{
student p1 = {1,”Brown”,123443};
student p2, p3;
p2.roll_no = 2;
strcpy(p2.name,”Sam”);
p2.phone_number = 1234567822;
p3.roll_no = 3;
strcpy(p3.name,”Addy”);
p3.phone_number = 1234567844;
cout<< “First Student” <<endl;
cout<< “roll no : ” << p1.roll_no <<endl;
cout<< “name : ” << p1.name <<endl;
cout<< “phone no ; ” << p1.phone_number <<endl;
cout<< “Second Student” <<endl;
cout<< “roll no : ” << p2.roll_no <<endl;
cout<< “name : ” << p2.name <<endl;
cout<< “phone no : ” << p2.phone_number <<endl;
cout<< “Third Student” <<endl;
cout<< “roll no : ” << p3.roll_no <<endl;
cout<< “name : ” << p3.name <<endl;
cout<< “phone no : ” << p3.phone_number <<endl;
return0;
}
Output
Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures 19

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 10.
Debug the error in the following program.
Answer:
Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures 20
Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures 21
Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures 22
MODIFIED PROGRAM
#include<iostream.h>
struct PersonRec
{
char lastName[10];
char firstName[10];
int age;
}
Person Rec PeopleArrayType[ 10];
void LoadArray(PeopleRec peop[10]);
void main( )
{
PersonRec people [10];
for (i = 0; i < 10; i++)
{
cout< < people[i].firstName< < ” <<peopie[i].lastName <<setw(10) <<people[i].age;
}
}
LoadArray(PersonRec peop[10])
{
for (int i = 0; i < 10; i++)
{
cout<< “Enter first name: “;
cin<<peop[i].firstName;
cout<< “Enter last name: “;
cin>>peop[i].lastName;
cout<< “Enter age: “;
cin>> peop[i].age;←
}

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

11th Computer Science Guide Arrays and Structures Additional Questions and Answers

Choose The Correct Answer 1 mark

Question 1.
…………….. is a user-defined which has the combination of data items with different data types.
a) Structure
b) Class
c) Union
d) Array
Answer:
a) Structure

Question 2.
…………………. allows to group of variables of mixed data types together into a single unit.
a) Structure
b) Class
c) Union
d) Array
Answer:
a) Structure

Question 3.
If the elements are of different data types,then ……………… cannot support.
a) Structure
b) Class
c) Union
d) Array
Answer:
d) Array

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 4.
Structure is declared using the keyword …………………
a) Structure
b) struct
c) Stru
d) STRUCT
Answer:
b) struct

Question 5.
Identify the structure name from the following; struct Student balu;
a) balu
b) struct
c) Student
d) None of these
Answer:
c) Student

Question 6.
Identify the structure variable (object) from the following: struct Student balu;
a) balu
b) struct
c) Student
d) None of these
Answer:
a) balu

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 7.
How much of memory is required for the object of the following structure in Dev C++.
struct Student
{
long rollno;
int age;
float weight;
}balu, frank;
a) 12 Bytes
b) 8 Bytes
c) 10 Bytes
d) None of these
Answer:
a) 12 Bytes

Question 8.
How much of memory is required for the object of the following structure in Turbo C++.
struct Student
{
long rollno;
int age;
float weight;
}balu, frank;
a) 12 Bytes
b) 8 Bytes
c) 10 Bytes
d) None of these
Answer:
c) 10 Bytes

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 9.
If the members are pointer types then ……………….. is used to access the structure members.
a) →
b) ←
c) .(dot)
d) None of these
Answer:
a) →

Question 10.
A structure without a …………….. is called an anonymous structure.
a) Name
b) Tag
c) Name/Tag
d) None of these
Answer:
c) Name/Tag

Question 11.
…………………… operator is used to accessing structure member.
a) ::
b) @
c) .(dot)
d) $
Answer:
c) .(dot)

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 12.
The structure declared within another structure is called a …………….. structure.
a) Nested
b) Group
c) Block
d) None of these
Answer:
a) Nested

Question 13.
……………. structures act as members of another structure.
a) Nested
b) Group
c) Block
d) None of these
Answer:
a) Nested

Question 14.
The members of the child structure can be accessed as …………………….
a) Child structure name. Parent structure name. Member name
a) Parent structure name. Child structure name. Member name
a) Parent structure name. Member name. Child structure name
a) Member name. Parent structure name. Child structure name
Answer:
a) Child structure name. Parent structure name. Member name

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 15.
A structure variable can be passed to a function in a similar way of passing any argument that is of ……………………. data type.
a) Derived
b) User-defined
c) Built-in
d) None of these
Answer:
c) Built-in

Question 16.
If the structure itself is an argument to a function, then it is called ………………..
a) Call by value
b) Call by Reference
c) Call by Expression
d) None of these
Answer:
a) Call by value

Question 17.
If the reference of the structure is passed as an argument then it is called ……………….
a) Call by value
b) Call by Reference
c) Call by Expression
d) None of these
Answer:
b) Call by Reference

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 18.
When a structure is passed as an argument to a function using ……………… method, any change made to the contents of the structure variable inside the function to which it is passed do not affect the structure variable used as an argument.
a) Call by value
b) Call by Reference
c) Call by Expression
d) None of these
Answer:
a) Call by value

Question 19.
In ……………….method of passing the structures to functions, any change made to the contents of structure variable inside the function are reflected back to the calling function.
a) Call by value
b) Call by Reference
c) Call by Expression
d) None of these
Answer:
b) Call by Reference

Question 20.
Structures are usually passed by reference method because ……………..
a) It saves the memory space
b) Executes faster
c) Both A and B
d) None of these
Answer:
c) Both A and B

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 21.
Identify the correct statement from the following.
a) A structured object can also be assigned to another structure object only if both the objects are of the same structure type.
b) The structure elements can be initialized either by using separate assignment statements or at the time of declaration by surrounding its values with braces.
c) Array of structure variable can also be created.
d) All the above
Answer:
d) All the above

Very Short Answers (2 Marks)

Question 1.
What is the drawback of an array?
Answer:
In any situation when more than one variable is required to represent objects of uniform data-types, array can be used. If the elements are of different data types, then array cannot support.
If more than one variable is used, they can be stored in memory but not in adjacent locations. It increases the time consumption while searching.

Question 2.
What is the advantage of structure?
Answer:
The structure provides a facility to store different data types as a part of the same logical element in one memory chunk adjacent to each other.

Question 3.
What are global objects?
Answer:
Objects declared along with structure definition are called global objects

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 4.
Write note on the anonymous structure.
Answer:
A structure without a name/tag is called an anonymous structure.

Example:
struct
{
long rollno;
int age;
float weight;
} student;
The student can be referred to as a reference name to the above structure and the elements can be accessed like a student, roll no, student.age and student.weight

Question 5.
Define Nested structure.
Answer:
The structure declared within another structure is called a nested structure.

Question 6.
Give an example of nested structure.
Answer:
struct Student
{
int age;
float height, weight;
struct dob
{
int date;
char month[4];
int year;
};
}mahesh;

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 7.
How to access nested member structure?
Answer:
The nested structures act as members of another structure and the members of the child structure can be accessed as
parent structure name. Child structure name. Member name
Example:
mahesh. dob. date

Short Answers 3 Marks

Question 1.
Write the syntax of defining a structure? Give an example.
Answer:
Structure is declared using the keyword ‘struct’. The syntax of creating a structure is given below.
struct structure_name
{
type member-name1;
type member_name2;
} reference_name;
An optional field reference_name can be used to declare objects of the structure type directly.
Example:
struct Student
{
long rollno;
int age;
float weight;
};

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Question 2.
How memory is allocated for a structure?
Answer:
Consider the following structure :
struct Student
{
long rollno;
int age;
float weight;
};
In the above declaration of the struct, three variables rollno, age and weight are used. These variables (data element) within the structure are called members (or fields). In order to use the Student structure, a variable of type Student is declared and the memory allocation is shown in the following figure.
Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures 23

Question 3.
How will you refer structure elements?
Answer:
Referencing Structure Elements
Once the two objects of student structure type are declared, their members can be accessed directly.
The syntax for that is using a dot (.) between the object name and the member name. For example, the elements of the structure Student can be accessed as follows:
balu.rollno
frank, rollno
balu.age
frank.age
balu.weight
frank.weight

Samacheer Kalvi 11th Computer Science Guide Chapter 12 Arrays and Structures

Explain In Detail 5 Marks

Question 1.
Explain structure assignments in detail.
Answer:
Structure Assignments
Structures can be assigned directly instead of assigning the values of elements individually.
Example:
If Mahesh and Praveen are same age and same height and weight then the values of Mahesh can be copied to Praveen struct Student
{
int age;
float height, weight;
}mahesh;
The age of Mahesh is 17 and the height and weights are 164.5 and 52.5 respectively.The following statement will perform the assignment.
mahesh = {17, 164.5, 52.5};
praveen = mahesh;
will assign the same age, height and weight to Praveen.

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Tamilnadu State Board New Syllabus Samacheer Kalvi 11th Computer Science Guide Pdf Chapter 11 Functions Text Book Back Questions and Answers, Notes.

Tamilnadu Samacheer Kalvi 11th Computer Science Solutions Chapter 11 Functions

11th Computer Science Guide Functions Text Book Questions and Answers

Book Evaluation

Part I

Choose The Correct Answer

Question 1.
Which of the following header file defines the standard I/O predefined functions ?
a) stdio.h
b) math.h
c) string.h
d) ctype.h
Answer:
a) stdio.h

Question 2.
Which function is used to check whether a character is alphanumeric or not ?
a) isalpha( )
b) isdigit( )
c) isalnum( )
d) islower( )
Answer:
c) isalnum( )

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 3.
Which function begins the program execution ?
a) isalpha( )
b) isdigit( )
c) main( )
d) islower( )
Answer:
c) main( )

Question 4.
Which of the following function is with a return value and without any argument ?
a) x=display(int/ int)
b) x=display( )
c) y=display(float)
d) display(int)
Answer:
b) x=display( )

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 5.
Which is return data type of the function prototype of add (int, int); ?
a) int
b) float
c) char
d) double
Answer:
a) int

Question 6.
Which of the following is the scope operator ?
a) >
b) &
c) %
d) ::
Answer:
d) ::

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Part – II

Very Short Answers

Question 1.
Define Functions.
Answer:
A large program can typically be split into small subprograms (blocks) called functions where each sub-program can perform some specific functionality. Functions reduce the size and complexity of a program, make it easier to understand, test, and check for errors.

Question 2.
Write about strlen() function.
Answer:
The strlen() takes a null-terminated byte string source as its argument and returns its length. The length does not include the null(\0) character.
Example:
char source[ ] = “Computer Science”;
cout<<“\nGiven String is “<<source<<” its Length is “<<strlen(source);
Output
Given String is Computer Science its Length is 16

Question 3.
What are the importance of void data type?
Answer:
void type has two important purposes:

  1. To indicate the function does not return a value.
  2. To declare a generic pointer.

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 4.
What is Parameter and list its types?
Answer:
Arguments or parameters are the means to pass values from the calling function to the called function.
Types:

  1. The variables used in the function definition as parameters are known as formal parameters.
  2. The constants, variables, or expressions used j in the function call are known as actual parameters.

Question 5.
Write a note on Local Scope.
Answer:

  1. A local variable is defined within a block. A block of code begins and ends with curly braces { }.
  2. The scope of a local variable is the block in which it is defined.
  3. A local variable cannot be accessed from outside the block of its declaration.
  4. A local variable is created upon entry into its block and destroyed upon exit

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Part – III

Short Answers

Question 1.
What is Built-in functions?
Answer:
The functions which are available by default are known as “Built-in” functions. Ready-to-use subprograms are called pre-defined functions or built-in functions.

Question 2.
What is the difference between isupper() and toupper() functions?
Answer:
isupper():

  • This function is used to check the given character is uppercase.
  • This function will return 1 if true otherwise 0.

toupper():

  • This function is used to convert the given character into its uppercase.
  • This function will return the upper case equivalent of the given character. If the given character itself is in upper case, the output will be the same.

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 3.
Write about strcmp( ) function.
Answer:
strcmp( )
The strcmp( ) function takes two arguments: string 1 and string2. It compares the contents of string 1 and string2 lexicographically.
The strcmp() function returns a:

  • Positive value if the first differing character in string 1 is greater than the corresponding character in string2. (ASCII values are compared)
  • Negative value if the first differing character in string 1 is less than the corresponding character in string2,
  • 0 if string1 and string2 are equal.

Example:
#include <string.h>
#include <iostream>
using namespace std;
int main()
{
char string1[ ] = “Computer”;
char string2[ ] = “Science”;
int result;
result = strcmp(string1,string2);
if(result==0)
{
cout<<“String1 : “<<string1<<” and String2 : “<<string2 <<“Are Equal”;
}
else
{
cout<<“String1 :”<<string1<<” and String2 : “<<string2’ <<“ Are Not Equal”;
}
}
Output
String1 : Computer and String2 : Science Are Not Equa1

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 4.
Write short note on pow( ) function in C++.
Answer:
pow( ) function:
The pow( ) function returns base raised to the power of exponent. If any argument passed to pow( ) is long double, the return type is promoted to long double. If not, the return type is double.
The pow( ) function takes two arguments:

  • base – the base value
  • exponent – exponent of the base

#include <iostream>
#include <math.h>
using namespace std;
int main ( )
{
double base, exponent, result;
base = 5;
exponent = 4;
result = pow(base, exponent);
cout << “pow(“< double x = 25;;
result = sin(x);
cout << “\nsin(“<<x<<“)= “<<result;
return 0;
}
Output
pow(5^4) = 625
sin(25) = -0.132352

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 5.
What are the information the prototype provides to the compiler?
Answer:
The prototype above provides the following information to the compiler:

  1. The return value of the function is of type long.
  2. Fact is the name of the function.
  3. The function is called with two arguments:
    • The first argument is of int data type.
    • The second argument is of double data type, int display(int, int) // function prototype//.

The above function prototype provides details about the return data type, name of the function and a list of formal parameters or arguments.

Question 6.
What is default arguments ? Give example.
Answer:
default arguments:
In C++, one can assign default values to the formal parameters of a function prototype. The default arguments allows to omit some arguments when calling the function.

When calling a function,
For any missing arguments, complier uses the values in default arguments for the called function.
The default value is given in the form of variable initialization.

Example:
void defaultvalue(int n1=10, n2=100);
The default arguments facilitate the function call statement with partial or no arguments or complete arguments.

Example:
defaultvalue(x,y);
defaultvalue(200,150);
defaultvalue(150);
defaultvalue( );
The default values can be included in the function prototype from right to left, i.e., we cannot have a default value for an argument in between the argument list.

Example:
void defaultvalue(int n1 = 10, n2);//invalid prototype
void defaultvalue(int n1, n2 = 10);//valid prototype

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Part – IV

Explain in Detail

Question 1.
Explain the Call by value method with a suitable example.
Answer:
Call by value method:
This method copies the value of an actual parameter into the formal parameter of the function. In this case, changes made to the formal parameter within the function will have no effect on the actual parameter.

Example:
#include <iostream>
using namespace std;
void display(int 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

Question 2.
What is Recursion? Write a program to find GCD using recursion.
Answer:
A function that calls itself is known as a recursive function. And, this technique is known as recursion.

Finding GCD of any to number using Recursion:
GCD – Greatest Common Divisor or HCF (Highest Common Factor) or GCM – Greatest Common Measure)
#include <iostream>
using namespace std;
//Function to find HCF or GCD OR GCM // int gcd(int n1, int n2)
{
if (n2 != 0)
return gcd(n2, n1 % n2); //Recursive call of gcd function
else
return n1;
}
int main( )
{
int num1, num2;
cout << “Enter two positive integers: “;
cin >> num1 >> num2;
cout << “Greatest Common Divisor (GCD) of ” << num1;
cout<< ” & ” << num2 << ” is: ” << gcd(num1, num2);
return 0;
}
Output :
Enter two positive integers: 350 100
Greatest Common Divisor (GCD) of 350 & 100 is: 50

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 3.
What are the different forms of function return? Explain with example.
Answer:
Different forms of User-defined Function declarations:
Function without return value and without parameter
The following program is an example of a function with no return and no arguments passed.
The name of the function is display( ), its return data type is void and it does not have any argument.
#include <iostream>
using namespace std;
void display( )
{
cout<<“Function without parameter and return value”;
}
int main()
{
display( ); // Function calling statement//
return(O);
}
Output :
Function without parameter and return value
A Function with return value and without parameter
The name of the function is display(), its return type is int and it does not have any argument. The return statement returns a value to the calling function and transfers the program control back to the calling statement.

#include <iostream>
using namespace std;
int display( )
{
int a, b, s;
cout<<“Enter 2 numbers:
cin>>a>>b;
s=a+b;
return s;
}
int main( )
{
int m=display( );
cout<<“\nThe Sum=”<<m;
return(0);
}
OUTPUT :
Enter 2 numbers: 10 30
The Sum = 40

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 4.
Explain scope of variable with an example.
Answer:
Scope refers to the accessibility of a variable.
There are four types of scopes in C++

  1. Local Scope
  2. Function Scope
  3. File Scope
  4. Class Scope

1. Local Scope:

  • A local variable is defined within a block. A block of code begins and ends with curly braces {}.
  • The scope of a local variable is the block in which it is defined.
  • A local variable cannot be accessed from outside the block of its declaration.
  • A local variable is created upon entry into its block and destroyed upon exit;

Example:
int main( )
{
int a,b;   //Local variable
}

2. Function Scope:

  • The scope of a variable within a function is extended to the function block and all sub-blocks therein.
  • The lifetime of a function scope variable is the lifetime of the function block.

Example:
int. sum(int x, int y);  //x and y has function scope.

3. File Scope:

  • A variable declared above all blocks and functions (including main()) has the scope of a file.
  • The lifetime of a file scope variable is the lifetime of a program.
  • The file scope variable is also called a global variable.

Example:
#include
using namespace std;
int x,y; //x and y are global variable
void main()
{
……..
}

4. Class Scope:

  • Data members declared in a class has the class scope.
  • Data members declared in a class can be accessed by all member functions of the class.

Example:
Class example
{
int x,y; //x and y can be accessed by print() and void():
void print();
Void total();
};

Class Scope:
A class is a new way of creating and implementing a user-defined data type. Classes provide a method for packing together data of different types.
Data members are the data variables that represent the features or properties of a class.

class student
}
private:
int mark1, mark2, total;
};
The class student contains mark1, mark2, and total are data variables. Its scope is within the class of students only.

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 5.
Write a program to accept any integer number and reverse it.
Answer:
PROGRAM:
using namespace std;
#include <iostream>
int reverse(int num)
{
int r=0,d;
while(num>0)
{
d = num%10;
r = r*10+d;
num = num/10;
}
return (r);
}
int main( )
{
intx;
cout<<“\nEnter a number”;
cin>>x;
cout<<“\nReverse of the number is “<<reverse(x);
return 0;
}
OUTPUT
Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions 1

11th Computer Science Guide Functions Additional Questions and Answers

Choose The Correct Answer 1 Mark

Question 1.
………………. is the name of the function.
(a) Predefined
(b) Built-in
(c) Library
(d) All the above
Answer:
(d) All the above

Question 2.
…………….. reduce the size and complexity of a program, makes it easier to understand, test, and check for errors.
a) Arrays
b) Functions
c) Structures
d) Unions
Answer:
b) Functions

Question 3.
The strcpy() function takes two arguments of ……………….
(a) target and source
(b) upper and lower
(c) base and exponent
(d) none of these
Answer:
(a) target and source

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 4.
Functions which are available in the C++ language standard library is known as ……………… functions.
a) Built-in
b) User-defined
c) Either A or B
d) None of these
Answer:
a) Built-in

Question 5.
The pow() function takes the two arguments of ……………….
(a) target and source
(b) upper and lower
(c) base and exponent
(d) source and exponent
Answer:
(c) base and exponent

Question 6.
Why functions are needed?
a) Divide and conquer the purpose
b) Reusability of code
c) Reduce the complexity of a program
d) All the above
Answer:
d) All the above

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 7.
The C++ program always has a main() function to begin the program execution.
(a) 1
(b) 2
(c) 3
(d) null
Answer:
(a) 1

Question 8.
Ready-to-use subprograms are called ………………..
a) Pre-defined functions
b) Built-in functions
c) Either A or B
d) None of these
Answer:
c) Either A or B

Question 9.
In C++ the arguments can be passed to a function in ………………. ways.
(a) 2
(b) 1
(c) 3
(d) 7
Answer:
(a) 2

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 10.
A header file can be identified by their file extension ……………..
a) .head
b) .h
c) .hf
d) None of these
Answer:
b) .h

Question 11.
…………… is a header file contains pre-defined standard input/output functions.
a) conio.h
b) istream.h
c) iostream.h
d) stdio.h
Answer:
d) stdio.h

Question 12.
stdio.h header file defines the standard I/O predefined function ……………
a) getchar()
b) putchar()
c) getsQ and puts()
d) All the above
Answer:
d) All the above

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 13.
The predefined function ……………. is used to get a single character from the keyboard.
a) getchar()
b) putchar()
c) gets() and puts()
d) puts()
Answer:
a) getchar()

Question 14.
The predefined function …………… is used to display a single character.
a) getchar( )
b) putchar( )
c) gets( )
d) puts( )
Answer:
b) putchar( )

Question 15.
Function ……………… reads a string from standard input and stores it into the string pointed by the variable.
a) getchar( )
b) putchar( )
c) gets( )
d) puts( )
Answer:
c) gets( )

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 16.
Function …………….. prints the string read by gets() function in a newline.
a) getchar( )
b) putchar( )
c) gets( )
d) puts( )
Answer:
d) puts( )

Question 17.
……………. header file defines various operations on characters.
a) conio.h
b) ctype.h
c) iostream.h
d) stdio.h
Answer:
b) ctype.h

Question 18.
……………… function is used to check whether a character is alphanumeric or not.
a) isalnum( )
b) isalpha( )
c) isdigit( )
d) None of these
Answer:
a) isalnum( )

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 19.
………….. function returns a non-zero value if the given character is a digit or a letter, else it returns 0.
a) isalnum( )
b) isaipha( )
c) isdigit( )
d) None of these
Answer:
a) isalnum( )

Question 20.
The ……………… function is used to check whether the given character is an alphabet or not.
a) isalnum( )
b) isalpha( )
c) isdigit( )
d) None of these
Answer:
b) isalpha( )

Question 21.
………….. function will return 1 if the given character is an alphabet, and 0 otherwise 0.
a) isalnum( )
b) isalpha( )
c) isdigit( )
d) None of these
Answer:
b) isalpha( )

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 22.
………… function is used to check whether a given character is a digit or not.
a) isalnum( )
b) isalpha( )
c) isdigit( )
d) None of these
Answer:
c) isdigit( )

Question 23.
……………. function will return 1 if the given character is a digit, and 0 otherwise.
a) isalnum( )
b) isalpha( )
c) isdigit( )
d) None of these
Answer:
c) isdigit( )

Question 24.
………………. function is used to check whether a character is in lower case (small letter) or not.
a) islower( )
b) tolower( )
c) Both A and B
d) None of these
Answer:
a) islower( )

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 25.
……………. functions will return a non-zero value if the given character is a lower case alphabet, and 0 otherwise.
a) islower( )
b) tolower( )
c) toupper( )
d) isupper( )
Answer:
a) islower( )

Question 26.
……………. function is used to check the given character is uppercase.
a) islower( )
b) tolower( )
c) toupper( )
d) isupper( )
Answer:
d) isupper( )

Question 27.
……………. function will return 1 if the given character is an uppercase alphabet otherwise 0.
a) islower( )
b) tolower( )
c) toupper( )
d) isupper( )
Answer:
d) isupper( )

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 28.
…………. function is used to convert the given character into its uppercase.
a) islower( )
b) tolower( )
c) toupper( )
d) isupper( )
Answer:
c) toupper( )

Question 29.
………….. function will return the upper case equivalent of the given character.
a) islower( )
b) tolower( )
c) toupper( )
d) isupper( )
Answer:
c) toupper( )

Question 30.
………………… function is used to convert the given character into its lowercase.
a) islower( )
b) tolower( )
c) toupper( )
d) isupper( )
Answer:
b) tolower( )

Question 31.
………………. function copies the character string pointed by the source to the memory location pointed by the target.
a) strcpy( )
b) strcat( )
c) strcmp( )
d) strlen( )
Answer:
a) strcpy( )

Question 32.
The …………………. function takes a null-terminated byte string source as its argument and returns its length.
a) strcpy( )
b) strcat( )
c) strcmp( )
d) strlen( )
Answer:
d) strlen( )

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 33.
The length of the string does not include the _______ character.
a) Null(\0)
b) Blank space
c) White space
d) None of these
Answer:
a) Null(\0)

Question 34.
………………. function compares the contents of string1 and string2 lexicographically.
a) strcpy( )
b) strcat( )
c) strcmp( )
d) strlen( )
Answer:
c) strcmp()

Question 35.
The Strcmp( ) function returns a ………………. value if the first differing character in string1 is greater than the corresponding character in string2.
a) Positive
b) Negative
c) Zero
d) None of these
Answer:
a) Positive

Question 36.
The Strcmp() function returns a …………….. value if the first differing character in stringl is less than the corresponding character in string2.
a) Positive
b) Negative
c) Zero
d) None of these
Answer:
b) Negative

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 37.
………………. function appends copy of the character string pointed by the source to the end of string pointed by the target.
a) strcpy( )
b) strcat( )
c) strcmp( )
d) strlen( )
Answer:
b) strcat( )

Question 38.
The …………….. function is used to convert the given string into Uppercase letters.
a) strupr( )
b) toupper( )
c) Both A and B
d) None of these
Answer:
a) strupr( )

Question 39.
The …………….. function is used to convert the given string into Lowercase letters.
a) tolower( )
b) strlwr( )
c) Both A and B
d) None of these
Answer:
b) strlwr( )

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 40.
The cos( ) function takes a single argument in ………………
a) Radians
b) Degree
c) Either A or B
d) None of these
Answer:
a) Radians

Question 41.
The cos( ) function returns the value in the range of ……………
a) [0, 1]
b) [-1, 1]
c) [1,-1]
d) None of these
Answer:
b) [-1, 1]

Question 42.
The cos( ) function returns the value in ……………….
a) double
b) float
c) long double
d) Either A or B or C
Answer:
d) Either A or B or C

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 43.
The sqrt( ) function takes a …………… argument.
a) single non-negative
b) single negative
c) double non-negative
d) double negative
Answer:
a) single non-negative

Question 44.
If a negative value is passed as an argument to sqrt( ) function, a …………….. occurs,
a) Data type mismatch
b) Domain error
c) Prototype mismatch
d) None of these
Answer:
b) Domain error

Question 45.
The ………….. function returns, the value in the range of [-1,1].
a) cos( )
b) sin( )
c) Both A and B
d) None of these
Answer:
c) Both A and B

Question 46.
The …………….. function returns base raised to the power of the exponent.
a) exponent( )
b) power( )
c) pow( )
d) None of these
Answer:
c) pow( )

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 47.
If any argument passed to pow() is long double, the return type is promoted to ……………..
a) long double
b) int
c) double
d) char
Answer:
a) long double

Question 48.
The pow( ) function takes ……………… argument.
a) base
b) exponent
c) Both A and B
d) None of these
Answer:
c) Both A and B

Question 49.
The …………….. function in C++ seeds the pseudo-random number generator used by the rand() function.
a) srand( )
b) sran( )
c) rands( )
d) None of these
Answer:
a) srand( )

Question 50.
The srand( ) function is defined in ……………. header file.
a)
b) <stdlib)h>
c) or<stalib)h>
d) None of these
Answer:
c) or<stalib)h>

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 51.
C++ program can contain ……………. main”() function.
a) Only one
b) No
c) More than one
d) None of these
Answer:
a) Only one

Question 52.
In C++,……………… function begins the program execution.
a) void
b) main( )
c) User-defined
d) Built-in
Answer:
b) main( )

Question 53.
………………. data type is used to indicate the function does not return a value.
a) int
b) double
c) void
d) unsigned
Answer:
c) void

Question 54.
……………… data type is used to declare a generic pointer.
a) int
b) double
c) void
d) unsigned
Answer:
c) void

Question 55.
The user-defined function should be called explicitly using its ………………
a) Name
b) Arguments to be passed
c) Both A and B
d) None of these
Answer:
c) Both A and B

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 56.
Which of the following calling the function have a return value and with arguments?
a) display( );
b) display(x,y);
c) x = display( );
d) x = display(x,y);
Answer:
d) x = display(x,y);

Question 57.
Which of the following calling function have no return value and no argument?
a) display( );
b) display(x,y);
c) x = display();
d) x = display(x,y);
Answer:
a) display( );

Question 58.
Which of the following calling the function have no return value and with arguments?
a) display( );
b) display(x,y);
c) x = display();
d) x = display(x,y);
Answer:
b) display(x,y);

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 59.
Which of the following calling the function have a return value and no argument?
a) display();
b) display(x,y);
c) x = display();
d) x = display(x,y);
Answer:
c) x = display();

Question 60.
…………………. are the means to pass values from the calling function to the called function.
a) Arguments
b) Parameters
c) Arguments or Parameters
d) None of these
Answer:
c) Arguments or Parameters

Question 61.
The variables used in the function definition as parameters are known as ……………. parameters.
a) Formal
b) Actual
c) Ideal
d) None of these
Answer:
a) Formal

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 62.
The parameters used in the function call are known as ………………. parameters.
a) Formal
b) Actual
c) Ideal
d) None of these
Answer:
b) Actual

Question 63.
The ……………… can be used in the function call as parameters.
a) Constants
b) Variables
c) Expressions
d) All the above
Answer:
d) All the above

Question 64.
The …………….. arguments allow omitting some arguments when calling the function.
a) Default
b) Actual
c) Formal
d) None of these
Answer:
a) Default

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 65.
The default value is given in the form of …………………….
a) Variable declaration
b) Variable initialization
c) void
d) None of these
Answer:
b) Variable initialization

Question 66.
The default arguments facilitate the function call statement with ………………. arguments.
a) Partial
b) No
c) Complete
d) All the above
Answer:
d) All the above

Question 67.
The default values can be included in the function prototype from ……………….
a) Left to Right
b) Right to Left
c) Center to Left
d) None of these
Answer:
b) Right to Left

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 68.
The constant variable can be declared using the…………… keyword.
a) constant
b) Const
c) const
d) CONST
Answer:
c) const

Question 69.
The …………….. keyword makes variable value stable.
a) constant
b) Const
c) const
d) CONST
Answer:
c) const

Question 70.
The ……………… modifier enables to assign an initial value to a variable that cannot be changed later inside the body of the function,
a) void
b) Const
c) const
d) Unsinged
Answer:
c) const

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 71.
In C++, the arguments can be passed to a function in ……………. ways.
a) three
b) two
c) four
d) None of these
Answer:
b) two

Question 72.
In C++, the arguments can be passed to a function in ……………… method.
a) Call by value
b) Call by reference
c) Either A or B
d) None of these
Answer:
c) Either A or B

Question 73.
………………. method copies the value of an actual parameter into the formal parameter of the function.
a) Call by value
b) Call by reference
c) Either A or B
d) None of these
Answer:
a) Call by value

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 74.
In ……………. method, changes made to the formal parameter within the function will have no effect on the actual parameter.
a) Call by value
b) Call by reference
c) Either A or B
d) None of these
Answer:
a) Call by value

Question 75.
………… method copies the address of the actual argument into the formal parameter.
a) Call by value
b) Call by reference
c) Either A or B
d) None of these
Answer:
b) Call by reference

Question 76.
In the…………….. method, any change made in the formal parameter will be reflected back in the actual parameter.
a) Call by value
b) Call by reference
c) Either A or B
d) None of these
Answer:
b) Call by reference

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 77.
The definition of the functions is stored in …………….
a) Array
b) Call by reference
c) Structures
d) None of these
Answer:
b) Call by reference

Question 78.
………….. functions can be used to reduce the overheads like STACKS for small function definition.
a) Inline
b) Built-in
c) User-defined
d) None of these
Answer:
a) Inline

Question 79.
……………. reduces the speed of program execution.
a) Array
b) Stacks
c) Structures
d) Unions
Answer:
b) Stacks

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 80.
A(n) ………….. function looks like a normal function in the source file but inserts the function’s code directly into the calling program.
a) inline
b) Built-in
c) User-defined
d) None of these
Answer:
a) inline

Question 81.
To make a function inline, one has to insert the keyword …………….. in the function header.
a) Inline
b) Insert
c) INLINE
d) None of these
Answer:
a) Inline

Question 82.
……………. functions execute faster but require more memory space.
a) User-defined
b) Built-in
c) Inline
d) None of these
Answer:
c) Inline

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 83.
The inline function reduces the complexity of using …………………
a) Array
b) Stacks
c) Structures
d) Unions
Answer:
b) Stacks

Question 84.
Returning from the function is done by using the ……………… statement.
a) return
b) goto
c) break
d) continue
Answer:
a) return

Question 85.
The …………….. statement stops execution and returns to the calling function.
a) return
b) goto
c) break
d) continue
Answer:
a) return

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 86.
Identify the true statement from the following.
a) A return may or may not have a value associated with it.
b) If the return has a value associated with it, that value becomes the return value for the calling statement.
c) The return statement is used to return from a function.
d) AN the above
Answer:
d) AN the above

Question 87.
The functions that return no value are declared as ……………..
a) Null
b) void
c) Empty
d) None of these
Answer:
b) void

Question 88.
The data type of a function is treated as …………….. if no data type is explicitly mentioned.
a) Null
b) void
c) Empty
d) int
Answer:
d) int

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 89.
What is the return type of the following function prototype? add (int, int);
a) Null
b) void
c) Empty
d) int
Answer:
d) int

Question 90.
What is the return type of the following function prototype? double add (int, int);
a) float
b) void
c) double
d) int
Answer:
c) double

Question 91.
What is the return type of the following function prototype?
char *display();
a) float
b) string
c) double
d) char
Answer:
b) string

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 92.
A function that calls itself is known as ………….. function.
a) recursive
b) nested
c) invariant
d) variant
Answer:
a) recursive

Question 93.
A function that calls itself using …………. technique.
a) recursive
b) variant
c) invariant
d) recursion
Answer:
d) recursion

Question 94.
………………. is mandatory when a function is defined after the main() function.
a) Function prototype
b) Function parameters
c) Return statement
d) None of these
Answer:
a) Function prototype

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 95.
Scope refers to the accessibility of a ……………..
a) Function
b) Class
c) Variable
d) Constant
Answer:
c) Variable

Question 96.
There are ………… types of scopes in C++.
a) five
b) two
c) three
d) four
Answer:
d) four

Question 97.
…………….. is a type of variable scope.
a) Local
b) Function / File
d) Class
d) All the above
Answer:
d) All the above

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 98.
A …………… is a region or life of the variable and broadly speaking there are three places, where variables can be declared.
a) Scope
b) Access specifier
c) Location
d) None of these
Answer:
a) Scope

Question 99.
Variables inside a block are called …………… variables.
a) Local
b) Function
c) Class
d) File
Answer:
a) Local

Question 100.
Variables inside a function are called ………….. variables.
a) Local
b) Function
c) Class
d) File
Answer:
b) Function

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 101.
Variables outside of ail functions are called ………….. variables.
a) Local
b) Function
c) Class
d) Global
Answer:
d) Global

Question 102.
Variables inside a class are called ……………
a) Class variable
b) Data members
c) Member functions
d) Either A or B
Answer:
d) Either A or B

Question 103.
The scope of formal parameters is …………… scope.
a) Local
b) Function
c) Class
d) File
Answer:
b) Function

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 104.
A variable declared above all blocks and functions (including main ()) has the …………… scope.
a) Local
b) Function
c) Class
d) File
Answer:
d) File

Question 105.
The lifetime of a ………….. scope variable is the lifetime of a program.
a) Local
b) Function
c) Class
d) File
Answer:
d) File

Question 106.
The file scope variable is also called as ………….. variable.
a) Global
b) General
c) Void
d) None of these
Answer:
a) Global

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 107.
…………… provides a method for packing together data of different types.
a) Enumeration
b) Array
c) Class
d) All the above
Answer:
c) Class

Question 108.
……………… represent the features or properties of a class.
a) Member function
b) Data member
c) Global variable
d) None of these
Answer:
b) Data member

Question 109.
…………….. is a scope resolution operator.
a) ? :
b) #
c) : :
d) &&
Answer:
c) : :

Question 110.
The …………… operator reveals the hidden scope of a variable.
a) ? :
b) &&
c) : :
d) #
Answer:
c) : :

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Very Short Answers (2 Marks)

Question 1.
Write about reusability.
Answer:

  1. Few lines of code may be repeatedly used in different contexts. Duplication of the same code can be eliminated by using functions which improve the maintenance and reduce program size.
  2. Some functions can be called multiple times with different inputs.

Question 2.
Why functions are needed?
Answer:
To reduce the size and complexity of the program functions are used.

Question 3.
What are constant arguments and write their syntax?
Answer:
The constant variable can be declared using the const keyword. The const keyword makes variable, value stable. The constant variable should be initialized while declaring. The const modifier enables the assignment of an initial value to a variable that cannot be changed later inside the body of the function.
Syntax: (const )

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 4.
Write a note on the reusability of the code.
Answer:
Reusability:

  • Few lines of code may be repeatedly used in different contexts. Duplication of the same code can be eliminated by using functions which improve the maintenance and reduce program size.
  • Some functions can be called multiple times with different inputs.

Question 5.
What is function scope?
Answer:
Function Scope:

  1. The scope of variables declared within a function is extended to the function block and all sub-blocks therein.
  2. The lifetime of a function scope variable is the lifetime of the function block. The scope of.

Question 6.
What is the header file?
Answer:
C++ provides a rich collection of functions ready to be used for various tasks. The tasks to be performed by each of these are already written, debugged, and compiled, their definitions alone are grouped and stored in files called header files

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 7.
What is a built-in function?
Answer:
The ready-to-use subprograms are called pre-defined functions or built-in functions.

Question 8.
What is a user-defined function?
Answer:
C++ provides the facility to create new functions for specific tasks as per user requirements. The name of the task and data required is decided by the user and hence they are known as User-defined functions.

Question 9.
How a header file is identified?
Answer:
A header file can be identified by their file extension .h.
Example:
stdio.h

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 10.
Write note on stdio.h header file.
Answer:
This header file defines the standard I/O predefined functions getchar(), putchar(), gets(), puts() and etc.

Question 11.
What is the purpose of getchar() and putchar() functions?
Answer:
The predefined function getchar() is used to get a single character from the keyboard and putchar() function is used to display it.

Question 12.
What is the purpose of gets() and puts() functions?
Answer:
Function gets( ) reads a string including balance spaces from standard input and stores it into the string pointed by the variable. Function puts() prints the string read by gets() function in a newline.

Question 13.
Write note on isalpha( ) function.
Answer:
The isalpha( ) function is used to check whether the given character is an alphabet or not.
Syntax:
int isalpha(char c);
This function will return 1 if the given character is an alphabet, and 0 otherwise 0. The following statement assigns 0 to the variable n, since the given character is not an alphabet.
int n = isalphaC3′);
The statement is given below displays 1, since the given character is an alphabet.
cout << isalpha(‘a’); .

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 14.
Write the use of isdigit() function.
Answer:
This function is used to check whether a given character is a digit or not. This function will return 1 if the given character is a digit, and 0 otherwise.
Syntax:
int isdigit(char c);
When the following code is executed, the value of the variable n will be 1, since the given character is a digit.
char ch = ‘3’;
n = isdigit (ch);

Question 15.
How to copy a string into another string?
Answer:
The srcpy() function copies the character string pointed by the source to the memory location pointed by the target. The strcpy() function takes two arguments: target and source. The null terminating character (\0) is also copied.
Example:
char source[ ] = “Computer Science”;
char target[20]=”target”;
strcpy(target,source);

Question 16.
What is the purpose of strupr( ) and strlwr( ) functions?
Answer:

  • The strupr( ) function is used to convert the given string into Uppercase letters.
  • The strlwr( ) function is used to convert the given string into Lowercase letters.

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 17.
What is the use of return statement in a function?
Answer:
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.

Question 18.
Write note on scope resolution operator.
Answer:
The scope operator reveals the hidden scope ‘ of a variable. The scope resolution operator (::) is used for the following purposes.

To access a Global variable when there is a Local variable with same name. An example using Scope Resolution Operator.
PROGRAM :
#include <iostream>
using namespace std;
int x=45; // Global Variable x
int main()
{
int x = 10; // Local Variable x
cout << “\nValue of global x is ” << ::x;
cout << “\nValue of local x is ” << x;
return 0;
}
Output :
Value of global x is 45
Value of local x is 10

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Short Answers (3 Marks)

Question 1.
What is divide and conquer?
Answer:
Divide and Conquer:

  1. Complicated programs can be divided into manageable sub-programs called functions.
  2. A programmer can focus on developing, debugging, and testing individual functions.
  3. Many programmers can work on different functions simultaneously.

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 2.
Write about islower( ) function.
Answer:
islower( )
This function is used to check whether a character is in lower case (small letter) or not.
This function will return a non-zero value, if the given character is a lower case alphabet, and 0 otherwise.
Syntax:
int islower(char c);

After executing the following statements, the value of the variable n will be 1 since the given character is in lower case
char ch = ‘n’;
int n = islower(ch);

The statement given below will assign 0 to the variable n, since the given character is an uppercase alphabet.
int n = islower(‘P’);

Question 3.
What is digit()? Give example.
Answer:
This function is used to check whether a given character is a digit or not. This function will return 1 if the given character is a digit, and 0 otherwise.

Example:
using namespace std;
#include
#include int main( )
{

char ch;
cout << “\n Enter a Character:”; cin >> ch;
cout << “\n The Return Value of isdigit(ch) is << isdigit(ch);

}
Output – 1
Enter a Character: 3
The Return Value of isdigit(ch) is: 1

Output – 2
Enter a Character: A
The Return Value of isdigit(ch) is: 0

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 4.
Explain the method of comparing two strings.
Answer:
strcmp( ) function compares the contents of string 1 and string2 lexicographically. The strcmp() function takes two arguments: stringl and string2.

The strcmp( ) function returns a:

  • Positive value if the first differing character in stringl is greater than the corresponding character in string2. (ASCII values are compared)
  • Negative value if the first differing character in stringl is less than the corresponding character in string2.
  • 0 if stringl and string2 are equal.

Example:
#include <string.h>
#inciude <iostream>
using namespace std;
int main()
{
char string1[ ] = “Computer”;
char string2[ ] = “Science”;
int result;
result = strcmp(string1,string2);
if(result==0)
{
cout<<“String1: “<<string1<<“and String2 : “<<string2 <<“Are Equal”;
}
else
{
cout<<“String1 :”<<string1<<” and String2 : “c<<string2<<” Are Not Equal”;
}
}
Output
String1 : Computer and String2 : Science Are Not Equal

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 5.
What is a return statement with an example?
Answer:
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. The return statement is used to return from a function. It is categorized as a jump statement because it terminates the execution of the function and transfers the control to the called statement.

Example:
return(a + b); return(a);
return; // to terminate the function

Question 6.
Write note on sin() and cos() functions.
Answer:
cos() function
The cos() function takes a single argument in radians. The cosQ function returns the value in the range of [-1, 1], The returned value is either in double, float, or long double.
Example:
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
double x = 0.5, result;
result = cos(x);
cout << “COS(“<<x<<“)= “<<result;
}
Output
COS(0.5)= 0.877583
sin( ) function:
The sin() function takes a single argument in radians. The sin( ) function returns the value in the range of [-1, 1]. The returned value is either in double, float, or long double.

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 7.
Write about sqrt( ) and pow( ) functions.
Answer:
sqrt( ) function:
The sqrt( ) function returns the square root of the given value of the argument. The sqrt( ) function takes a single non-negative argument. If a negative value is passed as an argument to sqrt( ) function, a domain error occurs.
Example:
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
double x = 625, result;
result = sqrt(x);
cout << “sqrt(“<<x<<“) = “<<result;
return 0;
}
Output
sqrt(625) = 25
pow( ) function:
The pow( ) function returns base raised to the power of exponent. If any argument passed to pow() is long double, the return type is promoted to long double. If not, the return type is double.
The pow() function takes two arguments:
base – the base value
exponent – exponent of the base Example:
#include <iostream>
#include <math.h>
using namespace std;
int main ( )
{
double base, exponent, result;
base = 5;
exponent = 4;
result = pow(base, exponent);
cout << “pow(“< << “) = ” << result;
double x = 25;;
result = sin(x);
cout << “\nsin(“<<x<<“)= “<<result;
return 0;
}
Output
pow(5 ^ 4) = 625 sin(25)= -0.132352

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 8.
How will you generate a random numbers?
Answer:
The srand( ) function in C++ seeds the pseudo random number generator used by the rand( ) function. The seed for rand( ) function is 1 by default. It means that if no srand( ) is called before rand(), the rand() function behaves as if it was seeded with srand(1).
The srand( ) function takes an unsigned integer as its parameter which is used as seed by the rand() function. It is defined inor <stdlib,h>header file.
Example:
#include <iostream>
#include <cstdlib.h>
using namespace std;
int main()
{
int random = rand(); /* No srand() calls before rand(), so seed = 1 */
cout << “\nSeed = 1, Random number = ” << random;
srand(10);
/* Seed = 10 */
random = rand( );
cout << “\n\nSeed = 10, Random number=” << random;
return 0;
}
Output
Seed = 1, Random number = 41
Seed =10, Random number =71

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 9.
Write note on function prototype.
Answer:
Function Prototype:
C++ program can contain any number of functions. But, it must always have only one main( ) function to begin the program execution. We can write the definitions of functions in any order as we wish.

We can define the main( ) function first and all other functions after that or we can define all the needed functions prior to main( ). Like a variable declaration, a function must be declared before it is used in the program.
The declaration statement may be given outside the main( ) function.

Example:
long fact (int, double);
Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions 2

Question 10.
Explain Formal Parameters and Actual Parameters or Arguments.
Answer:
Formal Parameters and Actual Parameters or Arguments:
Arguments or parameters are the means to pass values from the calling function to the called function.

  • The variables used in the function definition as parameters are known as formal parameters.
  • The constants, variables or expressions used in the function call are known as actual parameters.

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions 3

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Explain in Detail (5 Marks)

Question 1.
Explain about generating random numbers with a suitable program.
Answer:
The srand() function in C++ seeds the pseudo-random number generator used by the rand() function. The seed for rand() function is 1 by default. It means that if no srand() is called before rand(), the rand() function behaves as if it was seeded with srand( 1). The srand() function takes an unsigned integer as its parameter which is used as seed by the rand() function. It is defined inor header file.
#include
#include using namespace std; int main()
{

int random = rand(); /* No srand() calls before rand(), so seed = 1*/
cout << “\nSeed = 1, Random number =” << random;
srand(10);
/* Seed= 10 */
random = rand();
cout << “\n\n Seed =10, Random number =” << random;
return 0;

}
Output:
Seed = 1, Random number = 41
Seed =10, Random number 71

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 2.
How will access function? Explain in detail.
Answer:
Accessing a function:
The user-defined function should be called explicitly using its name and the required arguments to be passed. The compiler refers to the function prototype to check whether the function has been called correctly.

If the argument type does not match exactly with the data type defined in the prototype, the compiler will perform type conversion, if possible. If type conversion is impossible, the compiler generates an error message.
Example :

1.display( )calling the function without a return value and without any argument.
2.display (x, y)calling the function without a return value and with arguments.
3.x = display()calling the function with a return value and without any argument.
4.x = display (x, y)calling the function with a return value and with arguments.

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 3.
Explain constant argument in detail.
Answer:
Constant Arguments:
The constant variable can be declared using const keyword. The const keyword makes variable value stable. The constant variable should be initialized while declaring. The const modifier enables to assign an initial value to a variable that cannot be changed later inside the body of the function.
Syntax:
<returntype> <functionname> (const <datatype variable=value>)

Example:
int minimum(const int a=10);
float area(const float pi=3.14, int r=5);

PROGRAM
#include <iostream>
using namespace std; ,
double area(const double r,const double pi=3.14)
{
return(pi*r*r);
}
int main ( )
{
double rad,res;
cout<<‘AnEnter Radius :”;
cin>>rad;
res=area(rad);
cout << “\nThe Area of Circle =”<<res;
return 0;
}
OUTPUT:
Enter Radius: 5
The Area of Circle =78.5
If the variable value “r” is changed as r=25;
inside the body of the function “area” then compiler will throw an error as “assignment of
read-only parameter ‘r’ “.
double area (const double r, const double pi= 3.14)
{
r=25;
return(pi*r*r);
}

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 4.
Explain about address method.
Answer:
This method copies the address of the actual argument into the formal parameter. Since the address of the argument is passed, any change made in the formal parameter will be reflected back in the actual parameter.
#include
using namespace std;
void display(int & x) //passing address of a//
{

x = x*x;
cout << “\n\n The Value inside display function (n1 x n1) :”<< x ;

}
int main()
{
intn 1;
cout << “\n Enter the Value for N1 cin >> n1;
cout << “\n The Value of N1 is inside main function Before passing:” << n1;
display(n1);
cout << “\n The Value of N1 is inside main function After passing (n1 x n1):”<< n1; retum(O);
}

Output:
Enter the Value for N1: 45
The Value of N1 is inside the main function Before passing: 45
The Value inside display function (n1 x n1) : 2025
The Value ofNl is inside the main function After passing (n1 x n1): 2025

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 5.
Explain inline function in detial.
Answer:
Inline function:
An inline function looks like normal function in the source file but inserts the function’s code directly into the calling program. To make a function inline, one has to insert the keyword inline in the function header.

This reduces the speed of program execution. Inline functions can be used to reduce the overheads like STACKS for small function definition.
Syntax:
inline return type function name (data type parametername1,… datatype parameternameN)
Advantages of inline functions:

  • Inline functions execute faster but requires more memory space.
  • Reduce the complexity of using STACKS.

PROGRAM
#include <iostream>
using namespace std;
inline float simpleinterest (float pi, float nl, float r1)
{
float si1=(p1*n1*r1)/100;
return(si1);
}
int main ( )
{
float si,p,n,r;
cout<<“\nEnter the Principle Amount Rs. :”;
cin> >p;
cout<<“\nEnter the Number of Years:”;
cin>>n;
cout<<“\nEnter the Rate of Interest :”;
cin>>r;
si=simpleinterest(p,n,r);
cout << “\nThe Simple Interest = Rs,”<<si;
return 0;
}
Output:
Enter the Principle Amount Rs. :60000
Enter the Number of Years :10
Enter the Rate of Interest :5
The Simple Interest = Rs.30000
Though the above program is written in the normal function definition format during compilation the function code (p1*n1*r1)/100 will be directly inserted in the calling statement i.e. si=simpleinterest(p,n,r);
This makes the calling statement to change as si= (p1*n1*r1)/100;

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Hands-On Practice

Write C++ program to solve the following problems:
Question 1.
Program that reads two strings and appends the first string to the second. For example, If the first string Is entered as Tamil and the second string is Nadu, the program should print Tamilnadu. Use string library header.
Answer:
PROGRAM :
#include <string.h>
#include <iostream>
using namespace std;
int main()
{
char firststr[50],secondstr[50];
cout<<“\nEnter First String “; cin> >firststr;
cout<<“\nEnter Second String”; cin>>secondstr;
strcat(firststr,secondstr); //concatenation process
cout << ”\nConcatenated string is : ” <<firststr;
return 0;
}
Output:
Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions 4

Question 2.
Program that reads a string and converts it to uppercase. Include required header files.
Answer:
PROGRAM :
#include <string.h>
#include <iostream>
using namespace std;
int main()
{
char str[50];
cout<<“\nEnter a String
cin>>str;
cout << “\nGvien string is : “<<str; strupr(str);
cout << “\nGvien string in Uppercase is :”<<str;
return 0;
}
Output :
Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions 5

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 3.
Program that checks whether a given character is an alphabet or not. If It is an alphabet, whether It Is lowercase character or uppercase- character? Include required header files.
Answer:
PROGRAM :
#include <string.h>
#include <iostream>
using namespace std;
int main( )
{
char ch;
cout<<“\nEnter a Character”;
cin>>ch;
if(isalpha(ch))
if(islower(ch))
cout << “\nGiven Character is an Alphabet and in Lowercase”;
else
cout << “\nGiven Character is an Alphabet and in Uppercase “;
else
cout << “\nGiven Character in not an Alphabet”;
return 0;
Output
Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions 6

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 4.
Program that checks whether the given character is alphanumeric or a digit Add appropriate header file
Answer:
PROGRAM :
#include <string.h>
#include <iostream>
using namespace std;
int main()
{
char ch;
cout<<“\nEnter a Character”;
cin>>ch;
if(isalnum(ch))
if(isdigit(ch))
cout << “\nGiven Character is an Alphanumeric and digit”;
else
cout << “\nGiven Character is an Alphanumeric but not digit”;
else
cout << “\nGiven Character in not an Alphanumeric or digit”;
return 0;
}
Output:
Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions 7

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 5.
Write a function called zero_small ( ) that has two integer arguments being passed by reference and sets smaller of the two numbers to 0. Write the main program to access this function.
Answer:
PROGRAM
using namespace std;
#include <iostream>
void zero_small(int &a, int &b)
{
if (a<b)
a= 0;
else
b=0;
}
int main( )
{
int num1,num2;
cout<<“\nEnter two numbers :”; cin>>num1>>num2;
cout<<“\nNumber before set small value as 0 through function : num1=” <<num1<<” num2=”<<num2;
zero_small(num1,num2);
cout<<“\nNumber after set small value as 0 through function : num1=” <<num1<<” num2=”<<num2;
}
Output :
Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions 8
Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions 9

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 6.
Write definition for a function sumseries ( ) in C++ with two arguments/ parameters – double x and int n. The function should return a value of type double and it should perform sum of the following series:
x-x2 /3! + x3 / 5! – x4 / 7! + x5 / 9! upto n terms.
Answer:
PROGRAM :
using namespace std;
#indude
double sumseries(double x, int n)
{
double sum=0,t;
int f=1,sign=1;
t=x;
inti=1‘,j=1;
while(i<=n)
{
sum = sum + sign * t/f;
j=j + 2;
i++;
f = f*j*(j-1);
t = t * x;
sign = -sign;
}
return(sum);
}
int main()
{
int i,x,n,f=1,sign=1;
cout<<“\nEnter X value …”;
cin>>x;
cout<<“\nEnter N value …”;
cin>>n;
cout<<“\nSUM OF THE SERIES = “<<sumseries(x,n);
return 0;
}
Output :
Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions 10

Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions

Question 7.
Program that Invokes a function calc ( ) which intakes two integers and an arithmetic operator and prints the corresponding result.
Answer:
PROGRAM :
using namespace std;
#include
void calc(int numl,int num2,char op)
{
int result;
switch(op)
{
case’+’:
result = num1 + num2;
cout<<“\nAdded value “<<result;
break;
case’-‘:
result = num1 – num2;
cout<<“\nSubtracted value “<< result;
break;
case’*’:
result = num1 * num2;
cout<<“\Multiplied value”<<result;
break;
case ‘/’:
result = num1 / num2;
cout<<“\nDivided value “<<result;
break;
default:cout<<“\nPROCESS COMPLETED”;
}
}
int main()
{
float n1,n2;
char op;
cout<<“\nl. Enter two numbers”; cin>>n1>>n2;
cout<<“\nEnter an Operaotr + or – or * Or / :”; cin>>op;
calc(nl,n2,op);
}
Output :
Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions 11
Samacheer Kalvi 11th Computer Science Guide Chapter 11 Functions 12

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Tamilnadu State Board New Syllabus Samacheer Kalvi 11th Computer Science Guide Pdf Chapter 10 Flow of Control Text Book Back Questions and Answers, Notes.

Tamilnadu Samacheer Kalvi 11th Computer Science Solutions Chapter 10 Flow of Control

11th Computer Science Guide Flow of Control Text Book Questions and Answers

Book Evaluation

Part I

Choose The Correct Answer

Question 1.
What is the alternate name of null statement?
a) No statement
b) Empty statement
c) Void statement
d) Zero statement
Answer:
b) Empty statement

Question 2.
In C++, the group of statements should enclosed within:
a) { }
b) [ ]
c)()
d)<>
Answer:
a) { }

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 3.
The set of statements that are executed again and again in iteration is called as:
a) condition
b) loop
c) statement
d) body of loop
Answer:
d) body of loop

Question 4.
The multi way branching statement:
a) if
b) if… else
c) switch
d) for
Answer:
c) switch

Question 5.
How many types of iteration statements?
a) 2
b) 3
c) 4
d) 5
Answer:
b) 3

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 6.
How many times the following loop will execute?
for (int i=0; i<10; i++)
a) 0
b) 10
c) 9
d) 11
Answer:
b) 10

Question 7.
Which of the following is the exit control loop?
a) for
b) while
c) do…while
d) if…else
Answer:
c) do…while

Question 8.
Identify the odd one from the keywords of jump statements:
a) break
b) switch
c) go to
d) continue
Answer:
b) switch

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 9.
Which of the following is the exit control loop?
a) do-while
b) for
c) while
d) if-else
Answer:
a) do-while

Question 10.
A loop that contains another loop inside its body:
a) Nested loop
b) Inner loop
c) In line loop
d) Nesting of loop
Answer:
a) Nested loop

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Part – II

Short Answers

Question 1.
What is a null statement and compound statement?
Answer:
null statement; The “null or empty statement” is a statement containing only a semicolon. It takes the flowing form: ;
// it is a null statement
compound Statement:
In C++, a group of statements enclosed by pair of braces {} is called as a compound statement or a block.
The general format of compound statement is:
{
statement1;
statement2;
statement3;
}

Question 2.
What is a selection statement? Write its types?
Answer:
The selection statement means the statements are executed depends upon a condition. If a condition is true, a true block (a set of statements) is executed, otherwise, a false block is executed. This statement is also called a decision statement or selection statement because it helps in making a decision about which set of statements are to be executed.
Types:

  1. Two-way branching
  2. Multiway branching

Question 3.
Correct the following code segment:
Answer:
if (x=1)
p= 100;
else
P = 10;
Correct code: (Equal to operator is wrongly given)
if (x==1)
p= 100;
else
p = 10;

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 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 is given is
(i) 2000
(ii) 2003
(iii) 2010
Answer:
i) 2000 AS INPUT
Output
Leap
ii) 2003AS INPUT
Output
Not Leap year
iii) 2010 AS INPUT
Output
Not Leap year

Question 5.
What is the output of the following code?
for (int i=2; i<=10 ; i+=2)
cout << i;
Answer:
Output
2 4 6 8 10

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 6.
Write a for loop that displays the number from 21 to 30.
Answer:
# include
using namespace std;
int main()
{
for (int = 21; i < 31; i++)
cout << “value of i:” << i << endl;
return 0;
}
Output:
Value of i: 21
Value of i: 22
Value of i: 23
Value of i: 24
Value of i: 25
Value of i: 26
Value of i: 27
Value of i: 28
Value of i: 29
Value of i: 30

Question 7.
Write a while loop that displays numbers 2,4, 6, 8…….20.
Answer:
While loop to
i = 2;
while(i<=20)
{
cout<< i <<“,”;
i = i+2;
}

Question 8.
Compare an if and a ? : operator.
Answer:
The if statement evaluates a condition, if the condition is true then a true-block is executed, otherwise false-block will be executed! Block may consists of one or more statements. The conditional operator (or Ternary operator) . is an alternative for ‘if else statement’. Here if the condition is true one statement otherwise another statement will be executed.

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Part – III

Short Answers

Question 1.
Convert the following if-else to a single conditional statement:
Answer:
if (x >= 10)
a = m + 5;
else
a = m;
a = (x >= 10)? m + 5 : m ;

Question 2.
Rewrite the following code so that it is functional:
Answer:
v = 5;
do;
{
total += v;
cout << total;
while v <=10
CORRECT CODE:
int v = 5;
do
{
total += v;
v++;
} while (v <= 10); cout << total;

Question 3.
Write a C++ program to print the multiplication table of a given number.
Answer:

# include
using namespace std;
int main ()
{

int num;
cout << “Enter Number to find its multiplication table”; cin >> num;
for (int a = 1; a < = 10; a++)
{
cout << num << “*” << a << “=” << num*a << endl;
}
return( );
}

Output
Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control 1

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 4.
Write the syntax and purpose of switch statement.
Answer:
The syntax of the switch statement is:
switch(expression)
{
case constant 1:
statement(s);
break;
case constant 2:
statement(s);
break;
.
.
.
.
default:
statement(s);
}
Purpose of switch statement:
The switch statement is a multi-way branch statement. It provides an easy way to dispatch execution to different parts of code based on the value of the expression.

Question 5.
Write a short program to print following series: a) 1 4 7 10…… 40
Answer:
PROGRAM
using namespace std;
#inciude
int main()
{
for(int i=1;i<=40;i=i+3)
cout<<i<<” “;
return 0;
}
Output
Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control 2

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Part – IV

Explain In Detail

Question 1.
Explain the control statement with a suitable example.
Answer:
Control statements are statements that alter the sequence of flow of instructions.
In a program, statements may be executed sequentially, selectively, or iteratively. Every programming language provides statements to support sequence, selection (branching), and iteration.
Selection statement:
Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control 3
The selection statement means the statement(s) are executed depends upon a condition. If a condition is true, a true block ¡s executed otherwise a false block is executed. This statement is also called a decision statement or selection statement because it helps in making decisions about which set of statements are to be executed.
Iteration statement:
Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control 4
The iteration statement is a set of the statement are repetitively executed depends upon conditions. If a condition evaluates to true, the set of statements (true block) is executed again and again. As soon as the condition becomes false, the repetition stops. This is also known as a looping statement or iteration statement.

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 2.
What entry control loop? Explain any one of the entry control loops with a suitable example.
Answer:
In an entry-controlled loop, the test- expression is evaluated before entering into a loop, while and for statements are called as entry controlled loop.
Working of while loop:
A while loop is a control flow statement that allows the loop statements to be executed as long as the condition is true. The while loop ¡s an entry-controlled loop because the test-expression is evaluated before the entering into a loop.
The while loop syntax is:
while (Test expression )
{
Body of the loop;
}
Statement-x;
In a while loop, the test expression is evaluated and if the test expression result is true, then the body of the loop is executed and again the control is transferred to the while loop. When the test expression result is false the control is transferred to statement-x.
The control flow and flow chart of the while loop is shown below.
Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control 5
Example:
#include <iostream>
using namespace std;
int main ()
{
int i=1,sum=0;
while(i<=10)
{
sum=sum+i;
i++;
}
cout<<“The sum of 1 to 10 is “<<sum; return 0;
}
Output
The sum of 1 to 10 is 55

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 3.
Write a program to find the LCM and GCD of two numbers.
Answer:
PROGRAM:
using namespace std;
#include <iostream>
int main()
{
int n1, n2, i, gcd;
cout<<“Enter two integers:”;
cin>>n1>>n2;
for(i=1; i <= n1 && i <= n2; ++i)
{
// Checks if i is factor of both integers
if(n1%i==0 && n2%i==0)
gcd = i;
}
int lcm = n1*n2 /gcd;
cout<<“\nG.C.M.OF”<<nl<<“and”<<n2<<”
is”<<gcd;
cout< < “\nL.C. M. OF “< < n 1 < < ” and ” < < n2< < ” is “<<lcm; return 0;
}
Output
Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control 6
Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control 7

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 4.
Write programs to find the sum of the following series:
Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control 8
Answer:
PROGRAM
using namespace std;
#include
int main()
{
int i,x,n,f=1,sign=1;
float sum=0,t;
cout<<“\nEnter N value”;
cin>>n;
cout<<“\nEnter x value …”;
cin>>x;
t=x;
for(i=1;i<=n;i++)
{
f = f * i;
sum = sum + sign * t/f;
t = t * x;
sign = -sign;
}
cout<<”SUM OF THE SERIES = “<<sum;
return O;
}
Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control 9
Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control 10
PROGRAM
using namespace std;
#include
int main()
{
int i,x,n;
float sum=0,t;
cout<<“\nEnter N value”;
cin>>n;
cout<<“\nEnter x value …”;
cin>>x;
t=x;
for(i=l;i<=n;i++)
{
sum = sum + t/i;
t = t * x;
}
cout<<“SUM OF THE SERIES = “<<sum;
}
Output
Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control 11

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 5.
Write a program to find sum of the series s=1 +x +x2 + ……..+xn
Answer:
PROGRAM
using namespace std;
#include
int main()
{
int sum=1,x,i,t,n;
cout<<“\nEnter N value”;
cin>>n;
cout<<“\nEnter x value … “;
cin>>x;
t=x;
for(i=l;i<=n;i++)
{
sum = sum + t;
t = t * x;
}
cout<<“SUM = “<<sum;
}
Output
Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control 12

11th Computer Science Guide Flow of Control Additional Questions and Answers

Choose The Correct Answer 1 Mark

Question 1.
The empty statement is otherwise called as ………………..
(a) Control statement
(b) Zero statement
(c) Null statement
(d) Block statement
Answer:
(c) Null statement

Question 2.
The basics of control structure are……………. statement.
a) Selection
b) Iteration
c) Jump
d) All the above
Answer:
d) All the above

Question 3.
Iteration statement is called as ………………..
(a) Null statement
(b) Block statement
(c) Selection statement
(d) Looping statement
Answer:
(d) Looping statement

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 4.
In a program, the action may be ……………..
a) Variable declarations
b) Expression evaluations
c) Assignment operations
d) All the above
Answer:
d) All the above

Question 5.
……………….. is a multi-path decision-making statement.
(a) if
(b) if-else
(c) else – if
(d) if-else ladder
Answer:
(d) if-else ladder

Question 6.
The ……………. is a statement containing only a semicolon.
a) Null
b) Empty statement
c) Both A and B
d) None of these
Answer:
c) Both A and B

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 7.
……………….. is more efficient than the if-else statement.
(a) Control statement
(b) Switch statement
(c) Empty statement
(d) Null statement
Answer:
(b) Switch statement

Question 8.
C++ allows a group of statements enclosed by pair of ……………..braces.
a) ()
b) { }
c) [ ]
d) < >
Answer:
b) { }

Question 9.
C++ supports types of iteration statements.
(a) 3
(b) 2
(c) 4
(d) 5
Answer:
(a) 3

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 10.
……………. statements alter the sequence of flow of instructions.
a) Control
b) Null
c) Compound
d) None of these
Answer:
a) Control

Question 11.
……………….. is used to transfer the control from one place to another place without any condition in a program.
(a) Break statement
(b) Continue statement
(c) goto statement
(d) All the above
Answer:
(c) goto statement

Question 12.
The ……………. statement are the statements, that are executed one after another only once from top to bottom.
a) Sequential
b) Selective
c) Iterative
d) None of these
Answer:
a) Sequential

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 13.
…………….. statements do not alter the flow of execution.
a) Sequential
b) Selective
c) Iterative
d) None of these
Answer:
a) Sequential

Question 14.
…………….. statements always end with a semicolon (;).
a) Sequential
b) Selective
c) Iterative
d) None of these
Answer:
a) Sequential

Question 15.
The ……………. statement means the statement (s) are executed depends upon a condition.
a) Sequential
b) Selective
c) Iterative
d) None of these
Answer:
b) Selective

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 16.
If a condition is true, a true block (a set of statements) is executed otherwise a false block is executed is called …………… statement.
a) Decision
b) Selection
c) Either A or B
d) None of these
Answer:
c) Either A or B

Question 17.
The ……………. statement is a set of the statement are repetitively executed depends upon conditions.
a) Sequential
b) Selective
c) Iterative
d) None of these
Answer:
c) Iterative

Question 18.
The condition on which the execution or exit from the loop is called ………………
a) Exit-condition
b) Test-condition
c) Either A or B
d) None of these
Answer:
c) Either A or B

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 19.
In C++, any non-zero is treated as …………… including negative numbers
a) False
b) True
c) Complement
d) None of these
Answer:
b) True

Question 20.
In C++, zero is treated as …………..
a) False
b) True
c) Complement
d) None of these
Answer:
a) False

Question 21.
Decisions in C++ are made using …………….. statement.
a) if..else
b) switch., case
c) Either A or B
d) None of these
Answer:
c) Either A or B

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 22.
……………. statement which chooses between two alternatives.
a) if..else
b) switch., case
c) Either A or B
d) None of these
Answer:
a) if..else

Question 23.
………………. creates branches for multiple alternatives sections of code, depending on the value of a single variable.
a) if..else
b) switch., case
c) Either A or B
d) None of these
Answer:
b) switch., case

Question 24.
…………. is a two-way branching statement.
a) if..else
b) switch., case
c) Either A or B
d) None of these
Answer:
a) if..else

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 25.
……………….. is a multiple branching statement.
a) if..else
b) switch., case
c) Either A or B
d) None of these
Answer:
b) switch., case

Question 26.
An if statement contains another if the statement is called …………….
a) Nested if
b) Compound if
c) Block if
d) Group if
Answer:
a) Nested if

Question 27.
The nested if can have ……………. forms.
a) four
b) two
c) three
d) five
Answer:
c) three

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 28.
……………. is nested if form.
a) If nested inside if part
b) If nested inside both if part and else part
c) If nested inside else part
d) All the above
Answer:
d) All the above

Question 29.
The ………….. is a multi-path decision-making statement.
a) if-else ladder
b) Simple if
c) if… else
d) None of these
Answer:
a) if-else ladder

Question 30.
In ……………..type of statement ‘if’ is followed by one or more else if statements and finally end with an else statement.
a) if-else ladder
b) Simple if
c) if… else
d) None of these
Answer:
a) if-else ladder

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 31.
The……………. operator is an alternative for the if-else statement.
a) Conditional
b) Ternary
c) Continue
d) Either A or B
Answer:
d) Either A or B

Question 32.
The conditional operator consists of …………….. symbols.
a) two
b) three
c) four
d) five
Answer:
a) two

Question 33.
The conditional operator takes …………….. arguments.
a) two
b) three
c) four
d) five
Answer:
b) three

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 34.
The switch statement is a …………… statement.
a) Multi-way branch
b) Two-way branch
c) Jump
d) None of these
Answer:
a) Multi-way branch

Question 35.
………….. statement provides an easy way to dispatch execution to different parts of code based on the value of the expression.
a) if..else
b) switch
c) goto
d) None of these
Answer:
b) switch

Question 36.
The ………………statement replaces multiple if-else sequences.
a) if..else
b) switch
c) go to
d) None of these
Answer:
b) switch

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 37.
The expression provided in the switch should result in a…………… value.
a) Constant
b) Variant
c) Null
d) None of these
Answer:
a) Constant

Question 38.
In switch statement …………… statement is optional.
a) default
b) break
c) Both A and B
d) None of these
Answer:
c) Both A and B

Question 39.
The …………… statement is used inside the switch to terminate a statement sequence.
a) default
b) break
c) continue
d) None of these
Answer:
b) break

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 40.
In a switch statement, when a ………….. statement is reached, the flow of control jumps to the next line following the switch statement.
a) go to
b) break
c) continue
d) None of these
Answer:
b) break

Question 41.
……………. statement checks only for equality.
a) go to
b) if,.else
c) continue
d) switch
Answer:
d) switch

Question 42.
………….. statement checks for equality as well as for logical expression.
a) go to
b) if..else
c) continue
d) switch
Answer:
b) if..else

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 43.
………….. statement uses a single expression for multiple choices.
a) go to
b) if..else
c) continue
d) switch
Answer:
d) switch

Question 44.
A(n) ………….. statement uses multiple statements for multiple choices.
a) go to
b) if..else
c) continue
d) switch
Answer:
b) if..else

Question 45.
The ……………. statement evaluates integer, character, pointer or floating-point type or Boolean type.
a) go to
b) if..else
c) continue
d) switch
Answer:
b) if..else

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 46.
……….. statement evaluates only character or an integer data type.
a) go to
b) if..else
c) continue
d) switch
Answer:
d) switch

Question 47.
If the expression inside the switch statement turns out to be false then statements are executed.
a) default
b) break
c) else block
d) None of these
Answer:
a) default

Question 48.
If the expression inside if turns out to be false, statement inside ………….. will be executed.
a) default
b) true block
c) else block
d) None of these
Answer:
c) else block

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 49.
The ………….. statement is more flexible.
a) switch
b) if
c) continue
d) None of these
Answer:
b) if

Question 50.
The …………… statement is more efficient than the if-else statement.
a) switch
b) go to
c) continue
d) None of these
Answer:
a) switch

Question 51.
Which is true related to the switch statement?
a) A switch statement can only work for the quality of comparisons.
b) No two case labels in the same switch can have identical values.
c) If character constants are used in the switch statement, they are automatically converted to their equivalent ASCII codes.
d) All the above
Answer:
d) All the above

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 52.
When a switch is a part of the statement sequence of another switch, then it is called as …………….. switch statement.
a) Iterative
b) Sequential
c) Nested
d) None of these
Answer:
c) Nested

Question 53.
A(n) ………….. is a sequence of one or more statements that are repeatedly executed until a condition is satisfied.
a) Iteration
b) Looping
c) Iteration or Looping
d) None of these
Answer:
c) Iteration or Looping

Question 54.
………….. is used to reduce the length of code, to reduce time, to execute the program and takes less memory space.
a) Iteration
b) Looping
c) Iteration or Looping
d) None of these
Answer:
c) Iteration or Looping

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 55.
C++supports ………….. types of iteration statements.
a) five
b) four
c) three
d) two
Answer:
c) three

Question 56.
C++ supports ………….. type of iteration statement.
a) for
b) while
c) do..while
d) All the above
Answer:
d) All the above

Question 57.
Every loop has …………….. elements.
a) five
b) four
c) three
d) two
Answer:
b) four

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 58.
Every loop has ………….. element.
a) Initialization expression
b) Test expression / Update expression
c) The body of the loop
d) All the above
Answer:
d) All the above

Question 59.
The control variable(s) must be initialized …………. the control enters into a loop.
a) after
b) before
c) Either A or B
d) None of these
Answer:
b) before

Question 60.
Whose value decides whether the loop-body will be executed or not?
a) Test expression
b) Update expression
c) Initialization expression
d) None of these
Answer:
a) Test expression

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 61.
In an ……….. loop, the test-expression is evaluated before entering into a loop,
a) Entry-controlled
b) Exit-controlled
c) Both A and B
d) None of these
Answer:
a) Entry-controlled

Question 62.
In an ………….. loop, the test-expression is evaluated before exiting from the loop.
a) Entry-controlled
b) Exit-controlled
c) Both A and B
d) None of these
Answer:
b) Exit-controlled

Question 63.
……………. is used to change the value of the loop variable.
a) Test expression
b) Update expression
c) Initialization expression
d) None of these
Answer:
b) Update expression

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 64.
……………. statement is executed at the end of the loop after the body of the loop is executed.
a) Test expression
b) Update expression
c) Initialization expression
d) None of these
Answer:
b) Update expression

Question 65.
In an …………. loop, first, the test expression is evaluated and if it is nonzero, the body of the loop is executed otherwise the loop is terminated.
a) Entry-controlled
b) Exit-controlled
c) Both A and B
d) None of these
Answer:
a) Entry-controlled

Question 66.
In an …………. loop, the body of the loop is executed first then the test-expression is evaluated.
a) Entry-controlled
b) Exit-controlled
c) Both A and B
d) None of these
Answer:
b) Exit-controlled

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 67.
………….. loop statement contains three different statements.
a) for
b) while
c) do..while
d) All the above
Answer:
a) for

Question 68.
The for statement contains ……………. statement
a) Test expression
b) Update expression
c) Initialization expression
d) All the above
Answer:
d) All the above

Question 69.
The for statement sections are separated by ………………
a) Semicolons
b) Colon
c) Comma
d) None of these
Answer:
a) Semicolons

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 70.
The initialization part of the loop is used to initialize variables or declare a variable which is executed …………… time(s).
a) Loop repeated
b) Only one
c) two
d) None of these
Answer:
b) Only one

Question 71.
How many times the following loop will be executed?
for (i=0; i <= 10; i++);
a) 10
b) 9
c) 11
c) None of these
Answer:
c) 11

Question 72.
If the body of the loop contains a ……………. statement(s), need not use curly braces.
a) Single
b) More than one
c) Either A or B
d) None of these
Answer:
a) Single

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 73.
In for loop, multiple initializations and multiple update expressions are separated by ……………
a) Semicolons
b) Colons
c) Commas
d) None of these
Answer:
c) Commas

Question 74.
In a for loop, which expression is optional?
a) Test expression
b) Update expression
c) Initialization expression
d) All the above
Answer:
d) All the above

Question 75.
What will be formed if the following loop is executed?
for( i=0; ++i);
a) Finite loop
b) Indefinite loop
c) No iteration
d) None of these
Answer:
b) Indefinite loop

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 76.
A loop that has no statement in its body is called an ……………
a) Empty loop
b) Indefinite loop
c) Finite loop
d) None of these
Answer:
a) Empty loop

Question 77.
Identify the empty loop from the following.
a) for( i+0 ; i<=5; +=i);
b) for( i+0 ; i<=5; +=i); {cout<<“C++”;>
c) for( i+0 ; i<=5; +=i) { }
d) All the above
Answer:
d) All the above

Question 78.
A ………….. loop is useful for pausing the program for some time.
a) Time delay
b) Infinite loop
c) Finite loop
d) None of these
Answer:
a) Time delay

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 79.
……………. is a time delay loop.
a) for(i=l; i<=100; i++);
b) int i=l;
while( ++i < 10)
{
}
c) int i=l;
do
{
} while( ++i < 10);
d) All the above
Answer:
d) All the above

Question 80.
How many times the following loop will be executed?
int i=l;
while( ++i < 10)
cout<< “The value of i is “<<i;
a) 10
b) 9
c) 8
d) Infinite times
Answer:
c) 8

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 81.
How many times the following loop will be executed?
int i=l;
while( i++< 10)
cout<< “The value of i is “<<i;
a) 10
b) 9
c) 8
d) Infinite times
Answer:
b) 9

Question 82.
In ………… loop, the body of the loop will be executed atleast once.
a) while
b) do..while
c) for
d) All the above
Answer:
b) do..while

Question 83.
In ……………….. loop, the body of the loop is executed at least once, even when the condition evaluates false during the first iteration.
a) while
b) do..while
c) for
d) All the above
Answer:
b) do..while

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 84.
What will be the output of the following program?
using namespace std;
int main ()
{
int n = 10;
do
{
cout<<n<<“”; n-; }while (n>0);
}
a) 109 8 7 6 5 43 2 1
b) 10, 9, 8, 7, 6, 5, 4, 3, 2, 1
c) 1 2 3 4 5 6 7 8 9 10
d) 10, 9, 8, 7, 6, 5, 4, 3, 2, 1,0
Answer:
b) 10, 9, 8, 7, 6, 5, 4, 3, 2, 1

Question 85.
……………. statements are used to interrupt the normal flow of the program.
a) Jump
b) Loop
c) Decision making
d) None of these
Answer:
a) Jump

Question 86.
……………. is a jump statement.
a) go to statement
b) break statement
c) continue statement
d) All the above
Answer:
d) All the above

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 87.
The ………….. statement is a control statement which is used to transfer the control from one place to another place without any condition in a program.
a) go to
b) break
c) continue
d) All the above
Answer:
a) go to

Question 88.
A …………… statement is a jump statement which terminates the execution of the loop and the control is transferred to resume normal execution after the body of the loop.
a) go to
b) break
c) continue
d) All the above
Answer:
b) break

Question 89.
…………….. statement forces the loop to continue or execute the next iteration,
a) go to
b) break
c) continue
d) All the above statement is executed in
Answer:
c) continue

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 90.
When the …………….statement is executed in the loop, the code inside the loop following the …………… statement will be skipped and the next iteration of the loop will begin.
a) go to
b) break
c) continue
d) All the above
Answer:
c) continue

Question 91.
……………. statement breaks the iteration.
a) continue
b) break
c) Both A and B
d) None of these
Answer:
b) break

Question 92.
…………… statement skips the iteration.
a) continue
b) break
c) Both A and B
d) None of these
Answer:
a) continue

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 93.
…………….. statement is used with loops as well as switch case.
a) continue
b) break
c) Both A and B
d) None of these
Answer:
b) break

Question 94.
………….. statement is only used in loops.
a) continue
b) break
c) Both A and B
d) None of these
Answer:
a) continue

Very Short Answers (2 Marks)

Question 1.
What is an if statement? Write its syntax.
Answer:
The if statement evaluates a condition, if the condition is true then a true – block (a statement or set of statements) is executed, otherwise the true – block is skipped. The general syntax of the if the statement is:
if (expression)
true – block;
statement – x;

Question 2.
What are the basic control structures?
Answer:
The basics of control structures are:

  • Selection statement
  • Iteration statement
  • Jump statement

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 3.
What is a computer program?
Answer:
A computer program is a set of statements or instructions to perform a specific task.

Question 4.
What is nested if? Mention its types.
Answer:
An if statement contains another if the statement is called nested if. The nested can have, one of the following three forms.

  1. If nested inside if part
  2. If nested inside else part
  3. If nested inside both if part and else part

Question 5.
What are control statements?
Answer:
Control statements are statements that alter the sequence of flow of instructions.
In a program, statements may be executed sequentially, selectively, or iteratively. Every programming language provides statements to support sequence, selection (branching), and iteration.

Question 6.
What is the exit condition of a loop?
Answer:
The condition on which the execution or exit from the loop is called exit-condition or test-condition.

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 7.
What is an iteration or loop?
Answer:
An iteration or loop is a sequence of one or more statements that are repeatedly executed until a condition is satisfied. These statements are also called control flow statements.

Question 8.
What are the advantages of a loop or an iteration?
Answer:
It is used to reduce the length of code, to reduce time, to execute the program, and takes less memory space

Question 9.
What are loop elements?
Answer:
Every loop has four elements that are used for different purposes. These elements are

  1. Initialization expression
  2. Test expression
  3. Update expression
  4. The body of the loop

Question 10.
What are the parts of a loop?
Answer:
Every loop has four elements that are used for different purposes. These elements are:

  • Initialization expression
  • Test expression
  • Update expression
  • The body of the loop

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 11.
Write a note on the declaration of a variable in a for a loop.
Answer:
Declaration of a variable in a for loop:
In C++, the variables can also be declared within a for loop.
For instance,
for(int i=0; i<=5; ++i)
Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control 13
A variable declared inside the block of main() can be accessed anywhere inside main() i.e., the scope of variable in main().

Question 12.
Write a program to display numbers from 1 to 10 except 6 using a continue statement.
Answer:
C++ program to display numbers from 1 to 10 except 6 using continue statement
#include
using namespace std;
int main()
{
if (i = 6)
continue;
else
cout << i << ” ”
}
return 0;
}
Output:
1 2 3 4 5 7 8 9 10

Question 13.
Write about the go-to statement.
Answer:
go to the statement: The go-to statement is a control statement which is used to transfer the control from one place to another place without any condition in a program.
The syntax of the go-to statement is;
Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control 14
Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control 16
In the syntax above, the label is an identifier. When go-to label; is encountered, the control of the program jumps to label: and executes the code below ¡t.

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 14.
Write a note on the break statement.
Answer:
break statement: A break statement is a jump statement which terminates the execution of the loop and the control is transferred to resume normal execution after the body of the loop. The following figure shows the working of break statement with looping statements;
Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control 15

Question 15.
Write a note on the continue statement.
Answer:
continue statement:
The continue statement works quite similar to the break statement. Instead of terminating the loop, the continue statement forces the loop to continue or execute the next iteration. When the continue statement is executed in the loop, the code inside the loop following the continue statement will be skipped and the next iteration of the loop will begin.
The following figure describes the working flow of the continue statement
Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control 17

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Short Answers 3 Marks

Question 1.
Write a note on the sequence statement.
Answer:
sequence statement:
The sequential statement is the statements, that are executed one after another only once from top to bottom. These statements do not alter the flow of execution. These statements are called sequential flow statements. They always end with a semicolon (;).
Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control 18

Question 2.
What is a selection statement? Mention its types.
Answer:
Selection statement: The selection statement means the statement (s) are executed depends upon a condition. If a condition is true, a true block is executed otherwise a false block is executed. This statement is also called a decision statement or selection statement because it helps in making a decision about which set of statements are to be executed.
Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control 19

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 3.
Explain the Iteration statement.
Answer:
Iteration statement: The iteration statement is a set of the statement are repetitively executed depends upon conditions. If a condition evaluates to true, the set of statements (true block) is executed again and again. As soon as the condition becomes false, the repetition stops. This is also known as a looping statement or iteration statement.
Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control 20

Question 4.
Explain if statement with syntax and an example.
Answer:
The if statement evaluates a condition, if the condition is true then a true-block is executed, otherwise, the true-block is skipped.
Syntax: if (expression) true-block; statement-x;
In the above syntax, if is a keyword that should contain expression or condition which is enclosed within parentheses. Working of if statement: If the expression is true then the true-block is executed and followed by statement-x is also executed, otherwise, the control passes to statement-x. It is implemented in the following flowchart.
Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control 21
Example 1:
if ( qty> 500)
dis=10;
Example 2:
if(age>=18)
cout<< “\n You are eligible for voting ….”;

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 5.
Explain if..else statement with syntax and an example.
Answer:
The syntax of the if..else statement:
if (expression)
{
True-block;
}
else
{
False-block;
}
Statement-x
Working of if..else statement:
In if..else statement, first the expression or condition is evaluated as either true or false. If the result is true, then the statements inside the true-block are executed and the false-block is skipped. If the result is false, then the statement inside the false-block is executed i.e., the true-block is skipped. It is implemented in the following flowchart.
Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control 22
Example:
if(num%2==0)
cout<< “\n The given number is Even”;
else
cout<< “\n The given number is Odd”;

Question 6.
What is a conditional or ternary operator? Explain.
Answer:
The conditional operator (or Ternary operator) is an alternative for the ‘if-else statement’. The conditional operator consists of two symbols (?:). It takes three arguments. The control flow of the conditional operator is shown below.
The syntax of the conditional operator is:
expression 1? expression 2: expression 3
In the above syntax, expression 1 is a condition which is evaluated, if the condition is true (Non-zero), then the control is transferred to expression 2, otherwise, the control passes to expression 3.
Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control 23
Example:
#include
using namespace std;
int main()
{
int a, b, largest;
cout << “\n Enter any two numbers:
cin >> a >> b;
largest = (a>b)? a : b;
cout << “\n Largest number: ” << largest;
return 0;
}
Output
Enter any two numbers: 12 98
Largest number: 98

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 7.
Explain the nested switch statement.
Answer:
Nested switch:
When a switch is a part of the statement sequence of another switch, then it is called a nested switch statement. The inner switch and the outer switch constant may or may not be the same.
The syntax of the nested switch statement is: switch (expression)
{
case constant 1:
statement(s);
break;
switch(expression)
{
case constant 1:
statement(s);
break;
case constant 2:
statement(s);
break;
.
.
.
default: statement(s);
}
case constant 2:
statement(s);
break;
.
.
.
default:
statement(s);
}
Example:
#include
using namespace std;
int main()
{
int a = 8;
cout<<“The Number is : ” < switch (a)
{
case 0 :
cout<<“The number is zero” <<endl;
break;
default:
cout<<“The number is a non-zero
integer” <<endl;
int b = a % 2;
switch (b)
{
case 0:
cout<<“The number is even” <<endl;
break;
case 1:
cout<<“The number is odd” <<endl;
break;
}
}
return 0;
}
Output
The Number is: 8
The number is a non-zero integer
The number is even

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 8.
Explain variations of for loop?
Answer:
Variations of for loop:
Variations increase the flexibility and applicability of for loop.
Multiple initializations and multiple update expressions:
Multiple statements can be used in the initialization and update expressions of for loop.
This multiple initializations and multiple update expressions are separated by commas.
For example:
Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control 24
Output
The value of i is 0 The value of j is 10
The value of i is 1 The value of j is 9
The value of i is 2 The value of j is 8
The value of i is 3 The value of j is 7
The value of i is 4 The value of j is 6
In the above example, the initialization part contains two variables i and j, and the update expression contains i++ and j++. These two variables are separated by commas which are executed in sequential order i.e., during initialization firstly i-0 followed by j=10. Similarly, in update expression, firstly i++ is evaluated followed by j++ is evaluated.

Question 9.
Explain for loop optional expression with suitable examples.
Answer:
Optional expressions;
The for loop contains three parts, i.e., initialization expressions, test expressions and
update expressions. These three expressions are optional in a for loop.
Case 1:
#include
using namespace std;
int main ()
{
int i, sum=0, n;
cout<<“\n Enter The value of n”;
cin>>n;
i =1;
for (; i<=10;i++)
{
sum += i;
}
cout<<“\n The sum of 1 to” <<n<<“is “<<sum;
return 0;
}
Output
Enter the value of n 5
The sum of 1 to 5 is 15
In the above example, variable i is declared and the sum is initialized at the time of variable declaration.
The variable i is assigned to 0 before the for loop but still, the semicolon is necessary before test expression.
In a for loop, if the initialization expression is absent then the control is transferred to the test expression/conditional part.
Case 2:
#include
using namespace std;
int main ()
{
int i, sum=0, n;
cout<<“\n Enter The value of n”; cin>>n;
i =1;
for (; i<=10; )
{
sum += i;
++i;
cout<<“\n The sum of 1 to” <<n<<“is “<<sum;
return 0;
}
Output
Enter the value of n 5
The sum of 1 to 5 is 15
In the above code, the update expression is hot done, but a semicolon is necessary before the update expression.
Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control 25
In the above code, neither the initialization nor the update expression is done in the for a loop. If both or any one of the expressions are absent then the control is transferred to the conditional part.
Case 3:
An infinite loop will be formed if a test- expression is absent in a for a loop.
For example:
Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control 26

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 10.
What is an empty loop? Give a suitable example.
Answer:
Empty loop:
An empty loop means a loop that has no statement in its body is called an empty loop. Following for loop is an empty loop:
Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control 27
In the above code, the for loop contains a null statement, it is an empty loop.
Similarly, the following for loop also forms an empty loop.
Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control 28
In the above code, the body of a for loop enclosed by braces is not executed at all because a semicolon is ended after the for a loop.

Question 11.
What do you mean by the nesting of loops?
Answer:
Nesting of loops:
A loop which contains another loop is called a nested loop.
The syntax is given below:
for (initialization(s); test-expression; update expression(s))
{
for (initialization(s); test-expression; update expression(s)
{
statement(s);
}
statement(s);
{
Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control 29
Example:
#include
using namespace std;
int main(void)
{
cout<< “A multiplication table:”
< <<endl<< “” <<endl;
for(int c = 1; c < 10; C++)
{
cout<< c << “l”;
for(int i = 1; i< 10; i++)
{
cout< }
cout<<endl;
}
return 0;
}

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 12.
What are the Differences between the Break and Continue statement?
Answer:

Break

Continue

The break is used to terminate the execution of the loop.Continue is not used to terminate the execution of the loop.
It breaks the iteration.It skips the iteration.
When this statement is executed, control will come out from the loop and executes the statement immediately after the loop.When this statement is executed, it will not come out of the loop but moves/jumps to the next iteration of the loop.
The break is used with loops as well as switch cases.Continue is only used in loops, it is not used in switch cases.

Book Evaluation

Hands-On Practice
Write a C++ program to solve the following problems:
Question 1.
Temperature – conversion program that gives the user the option of converting Fahrenheit to Celsius or Celsius to Fahrenheit and depending upon the user’s choice.
Answer:
PROGRAM :
using namespace std;
#include<iostream>
int main()
{
float f,c;
int choice;
cout<<“\nl, FahrenheiT to Celsius”;
cout<<“\n2. Celsius to FahrenheiT”;
cout<<“\n3.Exit”;
cout<<“\nENTER YOUR CHOICE “;
cin>>choice;
switch(choice)
{
case 1: cout<<“\nENTER TEMPERATURE IN FAHRENHEIT “;
cin>>f;
c=5.0/9.0 *(f-32);
cout<<“\nTEMPERATURE IN FAHRENHEIT “<<f;
cout«”\nTEMPERATURE IN CELSIUS “<<c;
break;
case 2: cout<<“\nENTER TEMPERATURE IN CELSIUS “;
cin>>c;
f = 9*c/5 + 32;
cout< <“\nTEMPERATURE IN FAHRENHEIT “<<f;
cout< < “\nTEMPERATURE IN CELSIUS “<<c;
break;
default: cout< <“\nPROCESS COMPLETED”; > .
}
}
Output
Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control 30

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 2.
The program requires the user to enter two numbers and an operator. It then carries out the specified arithmetical operation: addition, subtraction, multiplication, or division of the two numbers. Finally, it displays the result.
using namespace std;
#include <iostream>
int main()
{
float num1,num2,result;
char op;
coutczcz”\nl. Enter two numbers”;
cin>>num1>>num2;
cout<<”\nEnter operaotr + or – or * or / : “; cin>>op;
switch(op)
{
case’+’:
result = num1 + num2;
cout<<“\nAdded value “<<result;
break;
case’-‘:
result = num1 – num2;
cout<<“\nSubtracted value “<<result;
break;
case ‘*’:
result = num1 * num2;
cout<<“\Multiplied value “<<result;
break;
case’/’:
result = num1 / num2;
cout<<“\nDivided value “<<result;
break;
default:cout<<“\nPROCESS COMPLETED”;
}
}
Output
Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control 31
Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control 32

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 3.
Program to input a character and to print whether a given character is an alphabet, digit or any other character.
Answer:
PROGRAM
using namespace std;
#include <iostream>
#include
int main()
{
char ch;
cout<<“\nl. Enter a character :”; cin>>ch;
if(isdigit(ch))
cout<<“\nThe given character “<<ch<<” is a digit”;
else if(isalpha(ch))
cout<<“\nThe given character “<<ch<<” is an alphabet”;
else
cout<<“\nThe given character “<<ch<<” is other character”;
}
Output
Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control 33

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 4.
Program to. print whether a given character Is an uppercase or a lowercase character or a digit or any other character. Use ASCII codes for it. The ASCII codes are as given below:
Answer:
Characters -ASCII Range
‘0’ – ‘9’ – 48 – 57
‘A’ – ‘Z’ – 65 – 90
‘a’ – ‘z’ – 97 – 122
other characters 0 – 255 excluding the above-mentioned codes.
PROGRAM
using namespace std;
#include
int main()
{
char ch;
cout<<“\nl. Enter a character: cin>>ch;
int av = ch;
if(av>47 m av<58)
cout<<“\nThe given character “<<ch<<” is a digit”; else if(av>64 && av<91)
cout<<“\nThe given character “<<ch<<” is an Uppercase character”; else if(av>96 && av < 123)
cout<<“\nThe given character “<<ch<<” is n Lowercase character”;
else
cout<<“\nThe given character “<<ch<<” is an Other character”;
}
Output
Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control 34
Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control 35

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 5.
Program to calculate the factorial of an integer.
Answer:
PROGRAM
using namespace std;
#include
int main()
{
int i,n;
long int fact=l;
cout<<“\nEnter a number… cin>>n; ‘
for(i=l; i<=n; i++)
fact = fact * i;
cout<<“\nFactorial of “<<n<<” is “<<fact;
}
Output
Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control 36

Question 6.
Program that print 1 2 4 8 16 32 64 128.
Answer:
PROGRAM
using namespace std;
#include
int main()
{
int i;
for(i=l; i< =128; i=i*2)
cout<<i<<“\t”;
}
Output
Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control 37

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 7.
Program to generate divisors of an integer.
Answer:
PROGRAM
using namespace std;
#include
int main() {
int n,d;
cout<<“\n Enter a number…”; cin>>n;
cout<<“\nThe divisors for “< for(d=l; d<=n/2;d++)
if(n%d==0)
cout<<d<<“\t”;
cout<<n;
}
Output
Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control 38

Question 8.
Program to print fibonacci series i.e., 0112 3 5 8
Answer:
PROGRAM
using namespace std;
#include
int main()
{
int n,fl,f2,f3;
fl=-l; ,
f2=l;
cout«”\nHOW MANY TERMS … “; .
cin>>n;
cout<<,r\nThe FIBONACCI TERMS ARE \n”; for(int i=l; i<=h;i++)
{
f3=fl+f2;
cout<<f3<<“\n”;
fl-f2;
f2=f3;
}
}
Output
Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control 39

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 9.
Programs to produces the following design using nested loops.
Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control 41
Answer:
9. A)
PROGRAM
using namespace std;
#include
int main()
{
int i,j;
for(i=l; i<=6; i++)
{
char c = ‘A’; for(j=l;j<=i;j++)
{
cout<<c<<“\t”;
C++;
}
cout<<“\n\n”;
}
}
Output
Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control 42
9. B)
PROGRAM
using namespace std;
#include
int main()
{
int i,j;
for(i=l; i<=5; i++) { for(j=5;j>=i;j–)
cout<<j<<“\t”;
cout<<“\n\n”;
}
}
Output
Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control 43
9.c)
PROGRAM
using namespace std;
#include
int main()
{
int i,j,k=0,m;
for(i=7; i> = l; i=i-2)
{
for(j=l;j<=i;j++)
cout<<“#\t”;
cout<<“\n\n”;
k++;
for(m=l;m<=k;m++)
cout<<“\t”;
}
}
Output
Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control 44

Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control

Question 10.
Program to check whether the square root of a number is a prime or not.
Answer:
PROGRAM
using namespace std;
#include
#include int main()
{
int n,srn,d,p=0;
cout<<“\nENTER A NUMBER … cin>>n;
srn=sqrt(n);
cout<<“\nTHE GIVEN NUMBER IS “<<n;
cout<<“\nTHE SQUARE ROOT OF”<<n<<” IS”<<srn;
for(d=2; d<=srn/2;d++)
{
if(srn%d==0)
{
p=1;
break;
}
}
if(p==0)
cout <<“\nTHE SQUARE ROOT OF THE GIVEN NUMBER “<<n<<” IS A PRIME”; else
cout <<“\nTHE SQUARE ROOT OF THE GIVEN NUMBER “<<n<<” IS NOT A PRIME”;
}
Output
Samacheer Kalvi 11th Computer Science Guide Chapter 10 Flow of Control 45