Class X Practical Assignments
Class X Practical Assignments
Create a class called Series which will contain the following member functions:
i)long fact(int f) -to find the factorial of f and return it.
ii) void sumseries(int x,int n) – to calculate and print the sum of the following series:
s=x+x/2!+ x/3!+…….x/n! [invoke long fact() method to find the factorial of the denominator)
iii) void main() -To create an object of the class Series and invoke the methods to enable the task.
Q2. Design a class to overload a function series() as follows:
i) double series (double n) with one double argument and returns the sum of the series
sum=1+1/2+1/3+…...+1/n
ii) double series (double a, double n) with two double arguments and return the sum of the series
sum=1/a2+4/a5+ 7/a8……….. n terms
Q3.Write a menu driven program to perform the following operation’s as per user’s choice.
i)To print the value of c=a2+2ab , where a varies from 1.0 to 20.0 with increment of 2.0 and b=3.0 is a
constant
ii) To display the following pattern using for loop
A
AB
ABC
ABCD
ABCD
ABCDE
Q4. Design a class to overload a method Number() as follows:
i) void number(int num , int d) – to count and display the frequency of a digit ina n umber
Example: num=564352,d=5
Output: Frequency of digit 5=2
ii) void number (int n1) – To find and display the sum of even digits of a number.
Example :n1=4532
Sum of even digits=6
Write a main method to create an object and invoke the above methods.
Q5. Define a class to overload the function print as follows:
i)void print() to print the following format
1111
2222
3333
4444
5555
ii)void print(int n) To check whether the number is a lead number. A lead number is the one whose sum of even digits
are equal to sum of odd digits. e.g. 3669 odd digits sum = 3 + 9 = 12 even digits sum = 6 + 6 = 12 3669 is a lead
number