icse-promo

ISC Theory Questions Solved

Share this page with your friends

Share on whatsapp
Share on facebook
Share on twitter
Share on telegram

Section-B

Question 7

Design a class ArmNum to check if a given number is an Armstrong number or not.
[A number is said to be Armstrong if sum of its digits raised to the power of length of the number is equal to the number]
Example : 371 = 33 + 73 + 13
1634 = 14 + 64 + 34 + 44
54748 = 55 + 45 + 75 + 45 + 85
Thus 371, 1634 and 54748 are all examples of Armstrong numbers.

Some of the members of the class are given below:
Class name:ArmNum

Data members/instance variables:
n:to store the number
l:to store the length of the number

Methods/Member functions:

ArmNum (int nn):parameterized constructor to initialize the data member n=nn

int sum_pow(int i):returns the sum of each digit raised to the power of the length of the number using recursive technique
eg. 34 will return 32 + 42 (as the length of the number is 2)

void isArmstrong( ):checks whether the given number is an Armstrong number by invoking the function sum_pow() and displays the result with an appropriate message

Specify the class ArmNum giving details of the constructor( ), int sum_pow(int) and void isArmstrong( ). Define a main( ) function to create an object and call the functions accordingly to enable the task

Question 8

Design a class MatRev to reverse each element of a matrix.

				
					72      371     5
12      6       426
5       123     94
				
			

Becomes

				
					27      173     5
21      6       624
5       321     49
				
			

Some of the members of the class are given below:
Class name:MatRev
Data members/instance variables:
arr[ ][ ]:to store integer elements
m:to store the number of rows
n:to store the number of columns
Member functions/methods:
MatRev(int mm, int nn):parameterised constructor to initialise the data members m = mm and n = nn
void fillarray( ):to enter elements in the array
int reverse(int x): returns the reverse of the number x
void revMat( MatRev P):reverses each element of the array of the parameterized object and stores it in the array of the current object
void show( ):displays the array elements in matrix form
Define the class MatRev giving details of the constructor( ), void fillarray( ), int reverse(int), void revMat(MatRev) and void show( ). Define the main( ) function to create objects and call the functions accordingly to enable the task.

Question 9

A class Rearrange has been defined to modify a word by bringing all the vowels in the
word at the beginning followed by the consonants.
Example: ORIGINAL becomes OIIARGNL
Some of the members of the class are given below:
Class name:Rearrange
Data member/instance variable:
wrd:to store a word
newwrd:to store the rearranged word
Member functions/methods:
Rearrange( ):default constructor
void readword( ):to accept the word in UPPER case
void freq_vow_con( ):finds the frequency of vowels and consonants in the word and displays them with an appropriate message
void arrange( ):rearranges the word by bringing the vowels at the beginning followed by consonants
void display( ):displays the original word along with the rearranged word
Specify the class Rearrange, giving the details of the constructor( ), void readword( ), void freq_vow_con( ), void arrange( ) and void display( ). Define the main( ) function to create an object and call the functions accordingly to enable the task.

Section-C

Question 10

A super class Record contains names and marks of the students in two different single dimensional arrays. Define a sub class Highest to display the names of the students obtaining the highest marks.
The details of the members of both the classes are given below:
Class name:Record
Data member/instance variable:
n[ ]:array to store names
m[ ] : array to store marks
size:to store the number of students
Member functions/methods:
Record(int cap):parameterized constructor to initialize the data member size = cap
void readarray():to enter elements in both the arrays
void display( ): displays the array elements
Class name:Highest
Data member/instance variable:
ind:to store the index
Member functions/methods:
Highest(…) :parameterized constructor to initialize the data members of both the classes
void find( ):finds the index of the student obtaining the highest mark and assign it to ‘ ind’
void display( ):displays the array elements along with the names and marks of the students who have obtained the highest mark
Assume that the super class Record has been defined. Using the concept of inheritance, specify the class Highest giving the details of the constructor(…),void find( ) and void display( ).
The super class, main function and algorithm need NOT be written.

Question 11

A linear data structure enables the user to add address from rear end and remove address from front. Define a class Diary with the following details:
Class name:Diary
Data members / instance variables:
Q[ ]:array to store the addresses
size:stores the maximum capacity of the array
start: to point the index of the front end
end:to point the index of the rear end
Member functions:
Diary (int max):constructor to initialize the data member size=max, start=0 and end=0
void pushadd(String n):to add address in the diary from the rear end if possible, otherwise display the message “NO
SPACE”
String popadd( ):removes and returns the address from the front end of the diary if any, else returns “?????”
void show( ):displays all the addresses in the diary
(a)Specify the class Diary giving details of the functions void pushadd(String) and String popadd( ).Assume that the other functions have been defined.
The main function and algorithm need NOT be written.

Question 12

A linked list is formed from the objects of the class Node. The class structure of the
Node is given below:

class Node

{

       int num;

      Node next;

}
Write an Algorithm OR a Method to find and display the sum of even integers from an existing linked list.
The method declaration is as follows:

void SumEvenNode( Node str )

Section-B

Question 7

Design a class Perfect to check if a given number is a perfect number or not. [ A number is said to be perfect if sum of the factors of the number excluding itself is equal to the original number]
Example : 6 = 1 + 2 + 3 (where 1, 2 and 3 are factors of 6, excluding itself)
Some of the members of the class are given below:
Class name Perfect
Data members/instance variables:
num:to store the number
Methods/Member functions:
Perfect (int nn):parameterized constructor to initialize the data member num=nn
int sum_of_factors(int i):returns the sum of the factors of the number(num), excluding itself, using recursive technique
void check():checks whether the given number is perfect by invoking the function sum_of_factors() and displays the result with an appropriate message
Specify the class Perfect giving details of the constructor (), int sum_of_factors(int) and void check (). Define a main () function to create an object and call the functions accordingly to enable the task.

Question 8

Two matrices are said to be equal if they have the same dimension and their corresponding
elements are equal.
For example, the two matrices A and B given below are equal:
Matrix A

				
					1   2   3

2   4   5

3   5   6
				
			

Matrix B

				
					27      173     5

21      6       624

5       321      49
				
			

Design a class EqMat to check if two matrices are equal or not. Assume that the two matrices have the same dimension.
Some of the members of the class are given below:
Class name:EqMat
Data members/instance variables:
a[ ][ ]:to store integer elements
m:to store the number of rows
n:to store the number of columns
Member functions/methods:
EqMat(int mm, int nn): parameterised constructor to initialize the data members m = mm and n = nn
void readarray( ):to enter elements in the array
int check(EqMat P, EqMat Q):checks if the parameterized objects P and Q are equal and returns 1 if true, otherwise returns 0
void print( ):displays the array elements
Define the class EqMat giving details of the constructor( ), void readarray( ), int check(EqMat, EqMat) and void print( ). Define the main( ) function to create objects and call the functions accordingly to enable the task.

Question 9

A class Capital has been defined to check whether a sentence has words beginning with a capital letter or not.
Some of the members of the class are given below:
Class name:Capital
Data member/instance variable:
sent:to store a sentence
freq :stores the frequency of words beginning with a capital letter
Member functions/methods:
Capital( ):default constructor
void input():to accept the sentence
boolean isCap(String w):checks and returns true if word begins with a capital letter, otherwise returns false
void display ():displays the sentence along with the frequency of the words beginning with a capital letter
Specify the class Capital, giving the details of the constructor( ), void input( ), boolean isCap(String) and void display( ). Define the main( ) function to create an object and call the functions accordingly to enable the task.

Section-C

Question 10

A super class Number is defined to calculate the factorial of a number. Define a sub class Series to find the sum of the series S = 1! + 2! + 3 ! + 4!+ . . . . . . . . . … . ..+n!
The details of the members of both the classes are given below:
Class name:Number
Data member/instance variable:
n:to store an integer number
Member functions/methods:
Number(int nn):parameterized constructor to initialize the data member n=nn
int factorial (int a):returns the factorial of a number (factorial of n = 1x 2x 3 x . . . . . . . . . x n)
void display():displays the data members
Class name:Series
Data member/instance variable:
sum:to store the sum of the series
Member functions/methods:
Series( . . .):parameterized constructor to initialize the data members of both the classes
void calsum( ):calculates the sum of the given series
void display( ):displays the data members of both the classes
Assume that the super class Number has been defined. Using the concept of inheritance, specify the class Series giving the details of the constructor( . . .), void calsum( ) and void display( ).
The super class, main function and algorithm need NOT be written.

Question 11

Register is an entity which can hold a maximum of 100 names. The register enables the user to add and remove names from the top most end only.
Define a class Register with the following details:
Class name:Register
Data members / instance variables:
stud[ ]:array to store the names of the students
cap:stores the maximum capacity of the array
top: to point the index of the top end
Member functions:
Register (int max):constructor to initialize the data member cap = max, top = -1 and create the string array
void push(String n):to add names in the register at the top location if possible, otherwise display the message “OVERFLOW”
String pop():removes and returns the names from the top most location of the register if any, else returns “$”
void display():displays all the names in the register
(a)Specify the class Register giving details of the functions void push(String) and String pop( ). Assume that the other functions have been defined .
The main function and algorithm need NOT be written .

Question 12

A linked list is formed from the objects of the class Node. The class structure of the Node is given below:
class Node
{
int n;
Node link;
}
Write an Algorithm OR a Method to search for a number from an existing linked list. The method declaration is as follows:
void FindNode( Node str, int b )

Section-B

Question 7

class Palin has been defined to check whether a positive number is a Palindrome number or not.
The number ‘N ‘ is palindrome if the original number and its reverse are same.
Some of the members of the class are given below:
Class name:Palin
Data members/instance variables:
num: integer to store the number
revnum:integer to store the reverse of the number
Methods/Member functions:
Palin( ):constructor to initialize data members with legal initial values
void accept( ):to accept the number
int reverse(int y):reverses the parameterized argument ‘y’ and stores it in ‘revnum’ using recursive technique
void check( ):checks whether the number is a Palindrome by invoking the function reverse( ) and display the result with an appropriate message
Specify the class Palin giving the details of the constructor ( ), void accept( ),int reverse( int ) and void check( ). Define the main( ) function to create an object and call the functions accordingly to enable the task.

Question 8

A class Adder has been defined to add any two accepted time.
Example: Time A – 6 hours 35 minutes
Time B – 7 hours 45 minutes
Their sum is – 14 hours 20 minutes ( where 60 minutes = 1 hour)
The details of the members of the class are given below:
Class name:Adder
Data member/instance variable:
a[ ]:integer array to hold two elements (hours and minutes)
Member functions/methods:
Adder( ):constructor to assign 0 to the array elements
void readtime():to enter the elements of the array
void addtime( Adder X, Adder Y):adds the time of the two parameterized objects X and Y and stores the sum in the current calling object
void disptime( ):displays the array elements with an appropriate message (i.e. hours = and minutes = )
Specify the class Adder giving details of the constructor( ), void readtime( ), void addtime(Adder, Adder) and void disptime( ). Define the main( ) function to create objects and call the functions accordingly to enable the task.

Question 9

A class SwapSort has been defined to perform string related operations on a word input. Some of the members of the class are as follows:
Class name SwapSort
Data members/instance variables:
wrd:to store a word
len:integer to store length of the word
swapwrd: to store the swapped word
sortwrd:to store the sorted word
Member functions/methods:
SwapSort( ):default constructor to initialize data members with legal initial values
void readword( ):to accept a word in UPPER CASE
void swapchar( ):to interchange/swap the first and last characters of the word in ‘wrd’ and stores the new word in ‘swapwrd’
void sortword( ):sorts the characters of the original word in alphabetical order and stores it in ‘sortwrd’
void display( )displays the original word, swapped word and the sorted word
Specify the class SwapSort, giving the details of the constructor( ), void readword( ), void swapchar( ), void sortword( ) and void display( ). Define the main( ) function to create an object and call the functions accordingly to enable the task.

Section-C

Question 10

A super class Product has been defined to store the details of a product sold by a wholesaler to a retailer. Define a sub class Sales to compute the total amount paid by the retailer with or without fine along with service tax.
Some of the members of both the classes are given below:
Class name:Product
Data member/instance variable:
name:stores the name of the product integer
code: to store the product code
amount:stores the total sale amount of the product (in decimals)
Member functions/methods:
Product(String n, int c, double p):parameterized constructor to assign data
members name=n, code=c and amount = p
void show( ) :displays the details of the data members Sales
Class name:Sales
Data member/instance variable:
day:stores number of days taken to pay the sale amount
tax:to store the service tax (in decimals)
totamt: to store the total amount (in decimals)
Member functions/methods:
Sales(…):parameterized constructor to assign values to data members of both the classes
void compute( ):calculates the service tax @ 12.4% of the actual sale amount
calculates the fine @ 2.5% of the actual sale amount only if the amount paid by the retailer to the wholesaler exceeds 30 days
calculates the total amount paid by the retailer as (actual sale amount + service tax + fine)
void show( ):displays the data members of super class and the total amount
Assume that the super class Product has been defined. Using the concept of inheritance, specify the class Sales giving the details of the constructor( …), void compute( ) and void show( ).
The super class, main function and algorithm need NOT be written.

Question 11

Queue is an entity which can hold a maximum of 100 integers . The queue enables the user to add integers from the rear and remove integers from the front.
Define a class Queue with the following details:
Class name Queue
Data Members / instance variables:
Que[ ] :array to hold the integer elements
size : stores the size of the array
front:to point the index of the front
rear:to point the index of the rear
Member functions:
Queue (int mm):constructor to initialize the data size = mm, front = 0, rear = 0
void addele(int v ):to add integer from the rear if possible else display the message “Overflow”
int delele( ):returns elements from front if present, otherwise displays the message “Underflow ” and return -9999
void display ( ):displays the array elements
Specify the class Queue giving details of ONLY the functions void addele(int) and int delele( ). Assume that the other functions have been defined.
The main function and algorithm need NOT be written.

Question 12

A linked list is formed from the objects of the class Node. The class structure of the Node is given below:
class Node
{
int num;
Node next;
}
Write an Algorithm OR a Method to count the nodes that contain only odd integers from an existing linked list and returns the count.
The method declaration is as follows:
int CountOdd( Node startPtr )

Section-B

Question 7

A disarium number is a number in which the sum of the digits to the power of their respective position is equal to the number itself.

Example:135=11+32+53
Hence,135 is a disarium number.
Design a class Disarium to check if a given number is a disarium number or not. Some of the members of the class are given below:

Classname:Disarium

Data members/ instance variables:
int num:stores the number
int size:stores the size of the number

Methods/Member functions:
Disarium(int nn):parameterized constructor to initialize the data members num=nn and size=0
void countDigit():counts the total number of digits and assigns it to size
int sumofDigits(int n,int p):returns the sum of digits of the number(n) to the power of their respective positions(p) using recursive technique
voidcheck():checks whether the number is a disariuim number and displays the result with an appropriate message

Specify the class Disarium giving the details of the constructor(),void countDigit(),int sumofDigits(int,int) and void check().Define the main() function to create an object and call the functions accordingly to enable the task.

Question 8

Design the class Shift to shuffle the matrix ( i.e. the first row becomes the last , the second row becomes the first and so on). The details of the members of the class is given below:

Classname:Shift

Data member/instance variable:
mat[ ][ ]:stores the array element
m:integer to store the number of rows
n:integer to store the number of columns
Member functions/methods:
Shift(int mm,int nn):parameterized constructor to initialize the data members m=mm and n=nn

void input():enter the element of the array
void cyclic(Shift P):enables the matrix of the object(P) to shift each row upwards in a cyclic manner and store the resultant matrix in the current object
void display():displays the matrix elements

Specify the class Shift giving details of the constructor(),void input(),void cyclic(Shift) and void display(). Define the main() function to create an object and call the methods accordingly to enable the task of shifting the array elements.

Question 9

A class ConsChange has been defined with the following details:

Class name:ConsChange
Data members/ instance variables:
word:stores the word
len:stores the length of the word

Member functions/methods:
ConsChange():default constructor
void readword():accepts the word in lower case
void shiftcons():shifts all the consonants of the word at the beginning followed by the vowels(e.g.spoon becomes spnoo)
void changeword():changes the case of all occuring consonants of the shifted word to upper case, for e.g.(spnoo becomes SPNoo)

void show():displays the original word,shifted word and the changed word

Specify the class ConsChange giving the details of the constructor( ), void readword(), void shiftcons(), void changeword() and void show(). Define the main() function to create an object and call the functions accordingly to enable the task.

Section-C

Question 10

 A super class Bank has been defined to store the details of a customer. Define a sub-class Account that enables transactions for the customer with the bank. The details of both the classes are given below:

Classname:Bank
Data member/instance variable:
name:stores the name of the customer
accno:stores the account number
p:stores the principal amount in decimals

Memberfunctions/methods:

Bank(…) :parameterized constructor to assign values to the instance variables
void display():displays the details of the customer

Classname:Account
Data member/instance variable:
amt:stores the transaction amount in decimals
Member functions/methods:
Account(…):parameterized constructor to assign values to the instance variables of both the classes

void deposit():accepts the amount and updates the principal as p=p+amt

void withdraw( ):accepts the amount and updates the principal as p=p-amt
If the withdrawal amount is more than the principal amount , then display the message “INSUFFICIENT BALANCE”. If the principal amount after withdrawal is less than 500, then a penalty is imposed by using the formula
p=p-(500-p)/10
void display():displays the details of the customer

Assume that the super class Bank has been defined. Using the concept of Inheritance, specify the class Account giving details of the constructor(…), void deposit( ),void withdraw() and void display().
The super class and the main function need not be written.

Question 11

A bookshelf is designed to store the books in a stack with LIFO(LastInFirstOut) operation. Define a class Book with the following specifications:
Classname:Book
Data members/instance variables:

name[ ]:stores the names of the books
point:stores the index of the top most book

max:stores the maximum capacity of the bookshelf
Methods/Member functions:
Book(int cap):constructor to initialise the data members max=cap and point=-1
void tell():displays the name of the book which was last entered in the shelf.If there is no book left in the shelf,displays the message”SHELF EMPTY”
void add(String v):adds the name of the book to the shelf if possible,otherwise displays the message”SHELF FULL”
void display():displays all the names of the books available in the shelf
Specify the class Book giving the details of ONLY the functions void tell( ) and void add(String). Assume that the other functions have been defined.
The main function need not be written.

Question 12

A linked list is formed from the objects of the class,
class Node
{
String name;
Node next;
}
Write a method OR an algorithm to search for a given name in the linked list.The method declaration is specified below:
boolean searchName(Node start,String v);

Section-B

Question 8

A class Admission contains the admission numbers of 100 students. Some of the data members / member functions are given below:
Classname:Admission
Data member/ instance variable:
Adno[ ]:integer array to store admission numbers
Member functions / methods:
Admission():constructor to initialize the array elements
void fillArray():to accept the elements of the array in ascending order
int binSearch:(int l,int u,int v):to search for a particular admission number(v) using binary search and recursive technique and returns 1 if found otherwise returns -1
Specify the class Admission giving details of the constructor, void fillArray() and int binSearch(int,int, int). Define the main() function to create an object and call the functions accordingly to enable the task.

Question 9

A class Merger concatenates two positive integers that are greater than 0 and produces a new merged integer.
Example:If the first number is 23 and the second is 764,then the concatenated number will be 23764.
Some of the members of the class are given below:
Classname:Merger
Data members/instance variables:
n1:long integer to store first number
n2:long integer to store second number
mergNum:long integer to store mergednumber
Member functions:
Merger():constructor to initialize the data members
void readNum():to accept the values of the data members n1 and n2
void JoinNum():to concatenate the numbers n1 and n2 and store it in mergNum
void show():to display the original numbers and the merged number with appropriate messages
Specify the class Merger,giving the details of the constructor,void readNum(),void JoinNum() and void show( ) . Define the main() function to create an object and call the functions accordingly to enable the task.

Question 10

 A class TheString accepts a string of a maximum of 100 characters with only one blank space between the words.
Some of the members of the class are as follows:
Classname:TheString
Data members /instance variables:
str:to store a string
len: integer to store the length of the string
wordcount:integer to store number of words
cons:integer to store number of consonants
Member functions/methods:
TheString():default constructor to initialize the data members
TheString(String ds):parameterized constructor to assign str=ds
void countFreq():to count the number of words and the number of consonants and store them in wordcount and cons respectively
voidDisplay(): to display the original string,along with the number of words and the number of consonants
Specify the class TheString giving the details of the constructors, void countFreq() and void Display(). Define the main() function to create an object and call the functions accordingly to enable the task

Section-C

Question 11

WordPile is an entity which can hold maximum of 20 characters .The restriction is that a character can be added or removed from one end only.Some of the members of classes are given below:
Classname:WordPile
Data members/instance variables:
ch[ ]:character array to hold the character elements
capacity:integer variable to store the maximum capacity
top:to point to the index of the top most element
Methods / Member functions:
WordPile( int cap):constructor to initialise the data member capacity=cap , top=-1 and create the WordPile
void pushChar(char v):adds the character to the top of WordPile if possible,otherwise output a message ”WordPile
is full”
char popChar():returns the deleted character from the top of the WordPile if possible,otherwise it returns ‘\\’
(a)Specify the class WordPile giving the details of the constructor, void pushChar(char) and char popChar().
THE MAIN() FUNCTION AND ALGORITHM NEED NOT BE WRITTEN.

Question 12

A line on a plane can be represented by coordinates of the two-end points p1 and p2 as p1(x1,y1) and p2(x2,y2).
A super class Plane is defined to represent a line and a subclass Circle to find the length of the radius and the area of circle by using the required data members of super class.
Some of the members of both the classes are given below:
Classname:Plane
Data members/instance variables:
x1:to store the x-coordinate of the first end point
y1:to store the y-coordinate of the first end point
Member functions/methods:
Plane(int nx,int ny):parameterized constructor to assign the data members x1=nx and y1=ny
void Show():to display the coordinates
Classname:Circle
Data members/instance variables:
x2:to store the x-coordinate of the second end point
y2:to store the y-coordinate of the second end point
radius:double variable to store the radius of the circle
area:double variable to store the area of the circle
Member functions / methods:
Circle(…):parameterized constructor to assign values to data members of both the classes
void findRadius():to calculate the length of radius using the formula:
(√(x2-x1)2+(y2-y1)2 )/2
assuming that x1, x2, y1, y2 are the coordinates of the two ends of the diameter of a circle
void findArea():to find the area of circle using formula: πr2.
The value of π is 22/7 or 3.14
void Show():to display both the coordinates along with the length of the radius and area of the circle
Specify the class Plane giving details of the constructor and void Show(). Using the concept of inheritance, specify the class Circle giving details of the constructor,void findRadius(),void findArea() and void Show().
The main function and algorithm need not be written.

Question 13

A linked list is formed from the objects of the class ,
class Node
{
int num;
Node next;
}
Write a method OR an algorithm to print sum of nodes that contains only odd integers of an existing linked list .The method declaration is specified below:
void NodesCount(Node startptr);

Section-B

Question 8

A class Mixer has been defined to merge two sorted integer arrays in ascending order.
Some of the members of the class are given below:
Classname:Mixer
Data members/instance variables:
int arr[ ]:to store the elements of an array
int n:to store the size of the array
Member functions:
Mixer(int nn):constructor to assign n=nn
void accept():to accept the elements of the array in ascending order without any duplicates
Mixer mix(Mixer A) : to merge the current object array elements with the parameterized array elements and return the resultant object
void display():to display the elements of the array

Specify the class Mixer, giving details of the constructor(int), void accept( ), Mixer mix(Mixer) and void display() . Define the main() function to create an object and call the function accordingly to enable the task.

Question 9

A class SeriesSum is designed to calculate the sum of the following series:
Sum=(x2 / 1!)+(x4 / 3!)+(x6 / 5!)+….(xn /(n- 1)!)
Some of the members of the class are given below:
Classname:SeriesSum
Data members / instance variables:
x:to store an integer number
n:to store number of terms
sum:to store the sum of the series
Member functions:
SeriesSum(int xx,int nn):constructor to assign x=xx and n=nn
double findfact(int m):to return the factorial of m using recursive technique.
double findpower(int x,int y):to return x raised to the power of y using recursive technique.
void calculate():to calculate the sum of the series by invoking the recursive functions respectively
void display():to display the sum of the series
Specify the class SeriesSum, giving details of the constructor(int, int),double findfact(int), double findpower(int , int), void calculate( ) and void display(). Define the main() function to create an object and call the functions accordingly to enable the task.

Question 10

A sequence of fibonacci strings is generated as follows:
S0=”a’ ‘ , S1=”b” , Sn=S(n-I)+S(n-2)) where ‘+’ denotes concatenation . Thus the sequence is : a, b, ba, bab, babba, babbabab, ……… n terms.
Design a class FiboString to generate fibonacci strings. Some of the members of the class are given below:
Classname:FiboString
Data members/instance variables:
x:to store the first string
y:to store the second string
z:to store the concatenation of the previous two strings
n:to store the number of terms
Member functions/methods:
FiboString():constructor to assign x=”a”,y=”b” and z=”ba”
void accept():to accept the number of terms ‘n’
void generate():to generate and print the fibonacci strings.The sum of(‘+ ‘ie concatenation) first two strings is the third string.Eg.”a” is first string,”b” is second string then the third will be “ba” , and fourth will be”bab” and so on.
Specify the class FiboString, giving details of the constructor(), void accept() and void generate() . Define the main() function to create an object and call the functions accordingly to enable the task.

Section-C

Question 11

A super class Stock has been defined to store the details of the stock of a retail store.Define a subclass Purchase to store the details of the items purchased with the new rate and updates the stock. Some of the members of the classes are given below:
Classname:Stock
Data members/instance variables:

item:to store the name of the item
qty:to store the quantity of an item in stock
rate:to store the unit price of an item
amt:to store the net value of the item in stock

Member functions:
Stock(…):parameterized constructor to assign values to the data members
void display():to display the stock details
Classname:Purchase
Data members/instance variables:
pqty: to store the purchased quantity
prate: to store the unit price of the purchased item
Member functions / methods:
Purchase(…):parameterized constructor to assign values to the data members of both classes
void update():to update stock by adding the previous quantity by the purchased quantity and replace the rate of the item if there is a difference in the purchase rate . Also update the current stock value as:
(quantity*unit price)
void display():to display the stock details before and after updation
Specify the class Stock,giving details of the constructor() and void display().Using concept of inheritance,specify the class Purchase,giving details of the constructor(),void update() and void display().
THE MAIN() FUNCTION AND ALGORITHM NEED NOT BE WRITTEN.

Question 12

A stack is a linear data structure which enables the user to add and remove integers from one end only,using the concept of LIFO(LastInFirstOut).An array containing the marks of 50 students in ascending order is to be pushed into the stack.
Define a class Array_to_Stack with the following details:

Classname:Array_to_Stack
Data members / instance variables:
m[ ]:to store the marks

st[]:to store the stack elements
cap:maximum capacity of the array and stack
top:to point the index of the top most element of the stack
Methods/Member functions:
Array_to_Stack(int n):parameterized constructor to initialize cap=n and top=-1
void input_marks():to input the marks from user and store it in the array m[ ] in ascending order and
simultaneously push the marks into the stack st[ ] by invoking the function pushmarks()
void pushmarks(int v):to push the marks into the stack at top location
if possible,otherwise,display “not possible”
int popmarks():to return marks from the stack if possible,otherwise, return -999
void display():To display the stack elements
Specify the class Array_to_Stack, giving the details of the constructor(int), void input_marks( ), void pushmarks(int), int popmarks() and void display().
The main function and algorithm need not be written.

Question 13

A linked list is formed from the objects of the class ,
class Node
{
    int number;
    Node nextNode;
}
Write a method OR an algorithm to add a node at the end of existing the linked list .The method declaration is specified below:
void addnode(Node start,int num);

Section-B

Question 8

 An Emirp number is a number which is prime backwards and forwards.
Example: 13 and 31 are both prime numbers. Thus,13 is an emirp number.
Design a class Emirp to check if a given number is Emirp number or not. Some of the members of the class are given below:
Classname:Emirp
Data members / instance variables:
n:stores the number
rev:stores the reverse of the number
f:stores the divisor
Member functions:

Emirp (int nn):to assign n= nn, rev=0 and f=2
int isprime(int x):check if the number is prime using the recursive technique and return 1 if prime otherwise return 0
void isEmirp(): reverse the given number and check if both the original number and the reverse number are prime , by invoking the function isprime(int) and display the result with an appropriate message

Specify the class Emirp giving details of the constructor(int) , int isprime(int) and void isEmirp(). Define the main() function to create an object and call the methods to check for Emirp number

Question 9

Design a class Exchange to accept a sentence and interchange the first alphabet with the last
alphabet for each word in the sentence,with single letter word remaining unchanged. The words in the input sentence are separated by a single blank space and terminated by a full stop.
Example: Input: It is a warm day.
Output: tI si a marw yad
Some of the data members and member functions are given below:

Classname:Exchange
Data members / instance variables:

sent: stores the sentence
rev: to store the new sentence
size: stores the length of the sentence

Member functions:

Exchange(): default constructor
void readsentence():to accept the sentence

void exfirstlast(): extract each word and interchange the first and last alphabet of the word and form a new sentence rev using the changed words

void display(): display the original sentence along with the new changed sentence.

Specify the class Exchange giving details of the constructor(), void readsentence() , void exfirstlast() and void display(). Define the main() function to create an object and call the functions accordingly to enable the task.

 

Question 10

A class Matrix contains a two dimensional integer array of order [m x n].The maximum value possible for both ‘m’ and ‘n’ is 25 . Design a class Matrix to find the difference of the two matrices . The details of the members of the class are given below:

Classname:Matrix
Data members/ instance variables:
arr[ ][ ]:stores the matrix element
m:integer to store the number of rows
n:integer to store the number of columns

Member functions:
Matrix(int mm,int nn): to initialize the size of the matrix m=mm and n=nn
void fillarray():to enter the elements of the matrix
Matrix SubMat(Matrix A):subtract the current object from the matrix of parameterized object and return the resulting object

void display():display the matrix elements

Specify the class Matrix giving details of the constructor(int,int ). void fillarray() ,Matrix SubMat(Matrix) and void display() . Also define a main() function to create an object and call the methods accordingly to enable the task.

Section-C

Question 11

 A super class Perimeter has been defined to calculate the perimeter of a parallelogram. Define a subclass Area to compute the area of the parallelogram by using the required data members of the super class. The details are given below:
Classname:Perimeter
Data members / instance variables:
a:to store the length in decimal
b:to store the breadth in decimal
Member functions:
Perimeter(…):parameterized constructor to assign values to data members
double Calculate():calculate and return the perimeter of a parallelogram as 2*(length+breadth)

void show():to display the data members along with the perimeter of the parallelogram

Classname:Area
Data members / instance variables:
h:to store the height in decimal
area:to store the area of the parallelogram
Member functions:
Area(…): parameterized constructor to assign values to data members of both the classes

void doarea():compute the area as (breadth*height)
void show():display the data members of both classes along with the area and perimeter of the parallelogram.

Specify the class Perimeter giving details of the constructor(…) , double Calculate() and void show(). Using the concept of inheritance, specify the class Area giving details of the constructor(…) , void doarea() and void show().
THE MAIN() FUNCTION AND ALGORITHM NEED NOT BE WRITTEN.

Question 12

A doubly queue is a linear data structure which enables the user to add and remove integers from either ends , i.e from front or rear. Define a class Dequeue with the following details:
Classname:Dequeue
Data members / instance variables:

arr[]:array to hold upto 100 integer elements
lim: stores the limit of the dequeue
front:to point to the index of front end
rear:to point to the index of rear end
Memberfunctions:

Dequeue(int l):constructor to initialize the data members lim=l,front=rear=0

void addfront(int val):to add integer from the front if possible else display the message(“Overflow from front”)
void addrear(int val):to add integer from the rear if possible else display the message(“Overflow from rear”)
int popfront():returns element from front, if possible otherwise returns -9999
int poprear():returns element from rear, if possible otherwise returns -9999

Specify the class Dequeue giving details of the constructor(int), void addfront(int) , void addrear(int) , int popfront() and int poprear().
The main function and algorithm need not be written.

Question 13

A linked list is formed from the objects of the class ,
class Node
{
int item;
Node next;
}
Write a method OR an algorithm to count the number of nodes in the linked list .The method declaration is specified below:
int count(Node ptr_start);

Section-B

Question 8

A class Combine contains an array of integers which combines two arrays into a single array including the duplicate elements if any and sorts the combined array .Some of the members of the class are given below:
Classname:Combine
Data members / instance variables:
com[ ]:integer array
size: size of the array
Member functions/methods:
Combine(int nn): parameterized constructor to assign size= nn

void inputarray():to accept the array elements
void sort():sorts the elements of combined array in ascending order using the selection sort technique
void mix(Combine A,Combine B):combines the parameterized object arrays and stores the result in the current object array along with duplicate elements if any
void display():displays the array elements

Specify the class Combine giving details of the constructor( int),void inputarray(),void sort() , void mix(Combine,Combine) and void display(). Also define the main() function to create an object and call the methods accordingly to enable the task.

Question 9

Design a class VowelWord to accept a sentence and calculate the frequency of words that begin with a vowel . The words in the input string are separated by a single blank space and is terminated by a full stop. The description of the class is given below:

Classname:VowelWord

Data members / instance variables:

str : to store a sentence

freq : store the frequency of the words beginning with a vowel

Member functions:
VowelWord( ): default constructor to initialize data member to legal initial value

void readstr(): to accept a sentence

void freq_vowel(): counts the frequency of the words that begin with a vowel

void display(): to display the original string and the frequency of the word that begin with a vowel

Specify the class VowelWord giving details of the constructor( ), void readstr( ) , void freq_vowel() and void display() . Also define the main() function to create an object and call the methods accordingly to enable the task.

Question 10

A happy number is a number in which the eventual sum of the square of the digits of the number is equal to 1.
Example:28=2^2+8^2=4+64=68
68=6^2+8^2=36+64=100
100=1^2+0^2+0^2=1 +0+0=1
Hence,28 is a happy number.
Example:12 =1^2+2^2=1+4=5
Hence, 12 is not a happy number.
Design a class Happy to check if a given number is a happy number.Some of the member of the class are given below:
Classname:Happy
Data members/ instance variables:
n: stores the number
Member functions:
Happy(): constructor to assign 0 to n
void getnum(int nn): to assign the parameter value to the number n=nn
int sum_sq_digits(int x): returns the sum of the square of the digit of the number x. using the recursive technique
void ishappy(): checks if the given number is a happy number by calling the function sum_sq_digits (int) and displays an appropriate message
Specify the class Happy giving details of the constructor( ). void getnum(int) , int sum_sq_digits(int) and void ishappy() . Also define a main() functionc to create an object and call the methods to check for happy number.

Section-C

Question 11

Link is an entity which can hold a maximum of 100 integers . Link enables the user to add elements from the rear end and remove integers from the front end of the entity. Define a class Link with the following details:
Classname:Link
Data members / instance variables:
lnk[ ]: entity to hold the integer elements
max:stores the maximum capacity of the entity
begin: to point to the index of the front end
end: to point to the index of the rear end
Member functions:
Link(int mm):constructor to initialize,max=mm,begin=0,end=0
void addlink(int v):to add an element from the rear index if possible otherwise display the message “OUT OF SIZE…”
int dellink():to remove and return an element from the front index , if possible otherwise display the message “EMPTY…” and return -99
void display():displays the elements of the entity

(a) Specify the class Link giving details of the constructor(int) void addlink(int), int dellink() and void display().
THE MAIN() FUNCTION AND ALGORITHM NEED NOT BE WRITTEN.

Question 12

A super class Detail has been defined to store the details of a customer.Define a sub class Bill to compute the monthly telephone charge of the customer as per the chart given below:

				
					NUMBER OF CALLS     RATE
1-100               only rental Charge
101-200             60 paisa per call +rental charge
201-300             80 paisa per call+rental charge
Above 300           1 rupee per call + rental charge
				
			

The details of both the classes are given below:
Classname:Detail
Data member / instance variables:
name: to store the name of the customer
address:to store the address of the customer
telno:to store the phone number of the customer
rent:to store the monthly rental charge
Member functions:

Detail(…): parameterized constructor to assign values to data members
void show(): to display the detail of the customer

Classname:Bill

Data members / instance variables:
n: to store the number of calls
amt:to store the amount to be paid by the customer

Member function:
Bill(…):parameterized constructor to assign value to data member of both classes and to initialize amt=0.0

void cal():calculates the monthly tel phone charge as per the chart given above

void show( ):display the details of the customer and amount to be paid

Specify the class Detail giving details of the constructor() and void show(). Using the concept of inheritance , specify the class Bill giving details of the constructor( ) , void cal() and void show().
THE MAIN() FUNCTION AND ALGORITHM NEED NOT BE WRITTEN

Question 13

A linked list is formed from the objects of the class ,
class node
{
int p;
String n;
node next;
}
Write a method OR an algorithm to search for a name and display the contents of that node .The method declaration is specified below:
void search(node start,String b);

Section-B

Question 8

Input a sentence from the user and count the number of times,the words “an” and “and” are present in
the sentence. Design a class Frequency using the description given below:
Class name:Frequency

Data Members/ variables :
text:stores the sentence
countand: to store the frequency of the word “and”
countan: to store the frequency of the word “an”
len: stores the length of the string

Member functions / methods:

Frequency( ) :constructor to initialize the instance variables

void accept(String n):to assign n to text,where the value of the parameter n should be in lower case.

void checkandfreq( ):to count the frequency of “and”
void checkanfreq( ):to count the frequency of “an”
void display( ):to display the number of”and” and “an” with appropriate messages.
Specify the class Frequency giving details of the constructor( ), void accept(String),void checkandfreq( ),void checkanfreq( ) and void display( ).Also define the main( ) function to create an object and call methods accordingly to enable the task.

Question 9

A class DeciOct has been defined to convert a decimal number into its equivalent octal number . Some of the members of the class are given below:

Classname:DeciOct

Data Members / instance variables:
n:stores the decimal number
oct:stores the octal equivalent number
Member functions:
DeciOct():constructor to initialize the data members , n=0, oct=0.
void getnum(int nn):assign nn to n
void deci_oct():calculates the octal equivalent of ‘n’ and stores it in oct using the recursive technique
void show():displays the decimal number ‘n’, calls the function deci_oct() and displays its octal equivalent.
Specify the class DeciOct, giving details of the constructor( ), void getnum(int),void deci_oct() and void show().Also define a main() function to create an object and call the functions accordingly to enable the task

Question 10

 You are given a sequence of N integers,which are called as pseudo arithmetic sequences(sequences that
are in arithmetic progression).
Sequence of N integers:2,5,6, 9,12
we observe that 2+12=5+ 9=6+8=14.
The sum of the above sequence can be calculated as 14 x 3 = 42.
For sequence containing an odd number of elements the rule is to double the middle element,for example
2,5,7,9,1
=2+12=5+9=7+7=14
14 x 3=42 [middle element= 7]
A class Pseudoarithmetic determines whether a given sequence is a pseudo-arithmetic sequence . The details of the class are given below:
Classname:Pseudoarithmetic
Data Members / Instance variables:
n:to store the size of the sequence
a[ ]:integer array to store the sequence of numbers
ans,flag:store the status
sum:store the sum of sequence of numbers
r:store the sum of the two numbers
Member functions:
Pseudarithmetic():default constructor
void accept(int nn): to assign nn to n and to create an integer array.
Fill in the elements of the array.

boolean check():return true if the sequence is a pseudo-arithmetic sequence otherwise returns false

 

Specify the class Pseudoarithmetlc , giving the details of the constructor() , void accept(int) and boolean check(). Also define main() function to create an object and call the member functions accordingly to enable the task.

Section-C

Question 11

A super class Record has been defined to store the names and ranks of 50 students. Define a sub-class
Rank to find the highest rank along with the name.The details of both classes are given below:
Classname:Record
Data Members / instance variables:
name[ ]:to store the names of students
mk[ ]:to store the ranks of students
Member functions:
Record():constructor to initialize data members
void readvalues():to store the names and ranks
void display():display the names and the corresponding ranks
Classname:Rank
Data members/ instance variables:
index: integer to store the index of the top most rank
Member functions:
Rank():constructor to invoke the base class constructor and to initialize index=0
void highest():finds the index/location of the top most rank and stores it in index without sorting the array.
void display():displays the names and ranks along with the name having the top most rank.
Specify the class Record giving details of the constructor(), void readvalues() and void display().Using the concept of inheritance, specify the class Rank giving details of constructor( ),void highest() and void display().
THE MAIN() FUNCTION AND ALGORITHM NEED NOT BE WRITTEN.

Question 12

 Stack is a kind of data structure which can store elements with the restriction that an element can be added or removed from the top only.
The details of the class Stack is given below:
Classname:Stack
Data Members/ instance variables:
st[]: the array to hold the names
size:the maximum capacity of the string array
top: the index of the top most element of the stack
ctr: to count the number of elements of the stack

Member functions:

Stack( ): default constructor
Stack(int cap):constructor to initialize size=cap and top=-1
void pushname(String n):to push a name into the stack. If the stack is full, display the message”OVERFLOW’
String popname( ):removes a name from the top of the stack and returns it. If the stack is empty,display the message “UNDERFLOW”
void display():Display the elements of the stack.

(a) Specify class Stack giving details of the constructors( ), void pushname (String n), String popname() and void display().
THE MAIN() FUNCTION AND ALGORITHM NEED NOT BE WRITTEN.

Question 13

A linked list is formed from the objects of the class ,
class Node
{
int info;
Node link;
}
Write a method OR an algorithm deleting a node in the linked list .The method declaration is specified below:
void deleteNode(Node start);

Section-B

Question 8

The coordinates of a point P on a two dimensional plane can be represented by P(x,y) with x as the x-coordinate and y as the y-coordinate.The coordinates of midpoint of two points P1(x1,yI) and P2(x2,y2) can be calculated as P(x,y) where:

 

x=(xl+x2)/2,y=(y1+y2)/2

Design a class Point with the following details:

 

Classname : Point

 

DataMembers / instancevariables:

x: stores the x-coordinate
y : stores the y-coordinate

 

Member functions:
Point():constructor to initialize x=0,y=0
void readpoint():accepts the coordinates x and y of a point
Point midpoint(PointA,PointB):calculates and returns the midpoint of the two
points A and B
void displaypoint():displays the coordinates of a point

 

Specify the class Point giving details of the constructor() , member functions void readpoint() ,Point midpoint(Point,Point) and void displaypoint() along with the main() function to create an object and call the functions accordingly to calculate the midpoint between any two given points.

Question 9

Input a word in uppercase and check for the position of the first occurring vowel and perform the
following operation.
(i)Words that begin with a vowel are concatenated with “Y”.
For example:- EUROPE becomes EUROPEY.
(ii) Words that contains a vowel in-between should have the first part from the position of the vowel till end , followed by the part of the string from beginning till position of the vowel and is concatenated by “C”.
For example – PROJECT becomes OJECTPRC.
(iii) Words which do not contain a vowel are concatenated with “N”.
For example – SKY becomes SKYN.
Design a class Rearrange using the description of the data members and member functions given below:
Classname:Rearrange
Data Members/instance variables:
Txt: to store a word
Cxt: to store the rearranged word
len: to store the length of the word
Member functions:
Rearrange():constructor to initialize the instance variables
void readword():to accept the word input in UPPERCASE
void convert():converts the word into its changed form and stores it in string Cxt
void display():displays the original and the changed word
Specify the class Rearrange giving the details of the constructor( ), void readword( ),void convert() and void display() . Define a main() function to create an object and call the function accordingly to enable the task.

Question 10

Design a class Change to perform string related operations . The details of the class are given below:
Classname: Change
Data Members / instance variables:
str :stores the word
newstr : stores the changed word
len: store the length of the word
Memberfunctions:
Change():default constructor
void inputword():to accept a word
char caseconvert(char ch) : converts the case of the character and returns it
void recchange(int):extracts characters using recursive technique and changes its case using caseconvert() and forms a new word
void display():displays both the words
(a) Specify the class Change, giving details of the Constructor(),member functions
void inputword(), char caseconvert(char ch),void recchange(int) and void display().
Define the main() function to create an object and call the functions accordingly to enable the above change in the given word.

 

Section-C

Question 11

A super class Worker has been defined to store the details of a worker .Define a sub clss Wages to compute the monthly wages for the worker. The details / specifications of both the classes are
given below:
Classname:Worker
Data Members / instance variables:
Name:to store the name of the worker
Basic:to store the basic pay in decimals
Memberfunctions:

Worker(…): Parameterised constructor to assign values to the instance variables

voiddisplay():
Classname: Wages
Data Members / instance variables:
hrs:stores the hours worked
rate:stores rate per hour
wage:stores the overall wage of the worker

Member functions:
Wages(…):Parameterised constructor to assign values to the instance variables of both the classes
double overtime():Calculates and returns the overtime amount as (hours*rate)
void display():Calculates the wage using the formula
wage = overtime amount+Basic pay
and displays it along with the other details
Specify the class Worker giving, details of the constructor() and void display().Using the concept of inheritance, specify the class Wages giving details of constructor( ), double overtime() and void display().The main() function need not be written.

Question 12

Define a class Repeat which allows the user to add elements from one end(rear) and remove elements from the other end(front)only.
The following details of the class Repeat are given below:

Classname:Repeat

Data Members/ instance variables:

st[]:an array to hold a maximum of
100 integer elements

cap:stores the capacity of the array

f:to point the index of the front

r:to point the index of the rear

Member functions:

Repeat(int m):constructor to initialize the data members cap=m, f=0,r=0 and to create the integer array

void pushvalue(int v):to add integers from the rear index if possible else display the message(“OVERFLOW”)

int popvalue():to remove and return element from the front.If array is empty then return -9999

void disp():Displays the elements present in the list

a) Specify.the class Repeat giving details of the constructor(int), member function void pushvalue(int) , int popvalue() and void disp() . The main() function need not be written.

Question 13

A linked list is formed from the objects of the class ,
class ListNodes
{
int item;
ListNodes next;
}
Write a method OR an algorithm to compute and return the sum of all integers items stored in the linked list .The method declaration is specified below:
int listsum(ListNodes start);

Coding Store