हिंदी

CISCE ISC (Science) ISC Class 12 Important Questions for Computer Science (Theory) - Methods

अध्याय

All topics
Advertisements
Advertisements

Chapter wise important questions with answers and solutions for Computer Science (Theory) in CISCE ISC (Science) ISC Class 12.

Design a class NumDude to check if a given number is a Dudeney number or not. (A Dudency number is a positive integer that is a perfect cube, such that the sum of its digits is equal to the cube root of the number.)

Example 5832 = (5 + 8 + 3 +2)3 = (18)3 = 5832

Some of the members of the class are given below:

Class name unique
Data member/instance variable:
num to store a positive integer number
Methods/Member functions:
NumDude() default constructor to initialise the data member with a legal initial value
void input() to accept a positive integer number
int sumDigits(int x) returns the sum of the digits of number 'x' using recursive technique
void isDude() checks whether the given number is a Dudeney number by invoking the function sumDigits() and displays the result with an appropriate message.

Specify the class NumDude giving details of the constructor ( ), void input( ), intsumDigits(int) and void is Dude(). Define a main() function to create an object and call the functions accordingly to enable the task.

Appears in 1 प्रश्न पत्र
अध्याय: [9] Methods
Concept: Examples of Algorithmic Problem Solving Using Functions (Various Number Theoretic Problems, Finding Roots of Algebraic Equations)

A class Trans is defined to find the transpose of a square matrix. A transpose of a matrix is obtained by interchanging the elements of the rows and columns.

Example: If size of the matrix = 3, then

ORIGINAL
11 5 7
8 13 9
1 6 20
TRANSPOSE
11 8 1
5 13 6
7 9 20

Some of the member of the class are given below:

Class name  Trans
Data members/instance variables:
arr[ ] [ ] to store integers in the matrix
m integer to store the size of the matrix
Methods/Member functions:
Trans(int mm) parameterised constructor to initialise the data member m = mm
void fillarray( ) to enter integer elements in the matrix
void transpose( ) to create the transpose of the given matrix
void display( ) displays the original matrix and the transposed matrix by invoking the method transpose( )

Specify the class Trans giving details of the constructor( ), void fillarray( ), void transpose( ) and void display( ). Define a main ( ) function to create an object and call the functions accordingly to enable the task.

Appears in 1 प्रश्न पत्र
अध्याय: [9] Methods
Concept: Examples of Algorithmic Problem Solving Using Functions (Various Number Theoretic Problems, Finding Roots of Algebraic Equations)
Advertisements
Share
Notifications



      Forgot password?
Use app×