1
© Himanshu Raj, Class 10A.
Copying strictly prohibited without
permission.
Name : HIMANSHU RAJ
CLASS 10 A ROLL-17
2
QUESTION 1(A):
WRITE A PROGRAM TO CALCULATE THE FACTORIAL
OF A NUMBER USING METHOD.
CODED SOLUTION:
OUTPUT:
variable description:
QUESTION1(B):
3
WRITE A PROGRAM TO FIND METHOD FACTORIAL OF
A NUMBER USING OOP
CODED SOLUTION:
OUTPUT:
variable description:
QUESTION 2:
Write the following program with the following specifications:
class name: Profit_Loss
Data members/Instant variables: int cp,sp
4
Member Method:
Profit_Loss : Default constructor to initialize cp,sp
void input (int a, int b): to assign a with cp and b with sp
void display (): To calculate and display either profit percent(pp) or loss percent (lp)
CODED SOLUTION:
OUTPUT:
5
Variable Description:
QUESTION 3:
6
CODED SOLUTION:
OUTPUT:
7
Variable Description:
QUESTION4:
Write a program with class name volume using function
overloading that compute the volume of cube, a sphere and
a cuboid.
Formula: volume of cube = s*s*s
8
Volume of sphere = 4/3*pi*r*r*r
Volume of cuboid = l*b*h.
CODED SOLUTION:
OUTPUT:
9
Variable Description:
QUESTION 5:
10
CODED SOLUTION:
11
OUTPUT:
Variable Description
QUESTION 6:
12
CODED SOLUTION:
13
OUTPUT:
14
variable description:
15
QUESTION 7:
WRITE A PROGRAM TO INPUT 10 NUMBERS IN A 1S
[Link] WETHER THE ELEMENT IS PRESENT
IN THE ARRAY USING LINEAR SEARCH
CODED SOLUTION:
16
OUTPUT:
variable description: