CFQ ISC Computer Science XII 31 32
CFQ ISC Computer Science XII 31 32
CFQ ISC Computer Science XII 31 32
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:
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)
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)