CFQ ISC Computer Science XII 31 32

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Computer Science ISC-Class XII

VI. Very Long Answer Questions (10 Marks Each)

S.No. Questions
71. [Programme based on Numbers]
An Automorphic number is a number whose square ends with the given number
itself. E.g. (5)2 = 25, (25)2 = 625, (76)2 = 5776.
Design a class Automorphic to check if numbers in the given range are
Automorphic numbers or not. The member functions and data members of the
class are given below:

Class Name : Automorphic


Data members/instance variables:
l, u :lower and upper limits of the range
count :frequency of the automorphic numbers in the range l and u
Member functions :
Automorphic(int l, int u): parameterised constructor to assign values to data
members
boolean check(int n) : to check if n is an automorphic number. If yes it returns
true otherwise returns false.
void list( ) : to check all the numbers between the range l and u, by
calling check(int n) and to display only the automorphic
numbers. Also to display the frequency of the
automorphic numbers in the given range.
Specify the class Automorphic giving details of the parameterised constructor,
boolean check(int n) and void list( ). Create one object in the main( )method and
call all the methods appropriately.
Sample input
Enter the lower limit of the range->1
Enter the upper limit of the range->1000

Sample output
List of Automorphic numbers from 1 to 1000 :
Number Square
1 1
5 25
6 36
25 625
76 5776
376 141376
625 390625
Frequency of Automorphic numbers between 1 to 1000 : 7
(Create)

ISC Competency-Focused Practice Questions 28


Computer Science ISC-Class XII

S.No. Questions
72. [Programme based on Strings]
Two words are called anagram of each other if both the words contain the same
letters but they are arranged in different order. Following are the three pairs of
the words which are anagrams of each other.
cat, act heart, earth silent, listen
Design the class Anagram to input two words in lower case and check if they are
anagram of each other. The member functions and data members of the class are
given below:
Class Name :Anagram
Data members/instance variables:
s1, s2 : stores the two words in lower case
l1,l2 : number of character in s1 and s2 respectively
Member functions :
Anagram(String s1, String s2): parameterised constructor to assign the accepted
values of s1 and s2 to data member
void sort(char c[]) : to sort the characters in array c[ ] in ascending
order using any sorting technique
boolean areAnagram(char[] str1, char[] str2)
: to check if str1 and str2 are anagrams of each
other and to return true or false accordingly
void check() : to convert the two strings into two character
arrays and to display the appropriate message as
shown in the sample output by calling the method
areAnagram(char[] str1, char[] str2)

Specify the class Anagram giving details of the parameterised constructor, void
sort(char c[ ]), boolean areAnagram(char[] str1, char[] str2) and void check( ).
Create one object in the main( )method and call all the methods appropriately.

Sample input
Enter first word->earth
Enter second word->heart

Output
earth and heart are anagram of each other
(Create)

ISC Competency-Focused Practice Questions 29

You might also like