Вы находитесь на странице: 1из 6

QUESTIONS

Q.1. A college maintains a list of its students graduating every year . At the end of the year ,the college
produces a report that lists following:
Year, Number of working graduates, number of non-working graduates, details of top scorer.
Write a program that uses inheritance path for below classes-
Person---Student---Graduate Student

Q2. A financial Instituion has only two types of account,Compound and Simple.The class account has two
protected attributes, acno and principal.
Write the function double interest() which calculates the appropriate interest and returns the interest for the
classes Simple and compound. Also write the function display for three classes. Write main() to test simple
and compound classes.

Q3. Define a class factorial with the following details:


Data Members: int fact,x;
Functions:
void input()
Int facto()
void setfact()
void display()
Also write the main method().

Q4. Define a class ArrayDel with following specifications:


Data Member: int a[20], lim.
Member functions:
Arraydel()
Void getdata()
Void delelement(int pos)
Void printlist()
Also write the main method to handle the above class.
Q5. A plastic company produces three types of balls
Class name: balls
Data members: count
Member methods:
balls()
void count_balls()
int show_count()
Write a main() method to input a string in upper case in the following format RRGGBBGRBGRGB
,where R=Red , B=Blue, G=green. Find and print number of balls.

Q.6. Define a class RevWord with


Data member char str[100]
Member functions-
Void getstring()
Void rev()
INPUT- my dear
OUTPUT- ym raed

Q7. Define class Recursive power with following specifications.


Class Name: Recursivepower
Data Members: int power,k,l.
Member Functions:
Recursivepower()
Vod input()
Int power(int m,int n)
Void setpower()
Void display()
Also write main method to handle the above class.

Q8. Define a class Print Prime with following specifications:


Class name: Printprime
Data member: char a[100]
Member functions:
Void getdata()
Void printp()
Input: PROGRAM
Output: OGA

Q9. Define a class Count Words which has data member char[str],n and calculates the number of words.
Words may have more than two spaces between them
Input: Hey how are you
Output: No.=4

Q.10 A classes D2point and D3point calculates the distance between two points in 2-D and 3-D space
respectively.
Class Name- D2point
Data members- double x,y
Member functions:
D2point()
D2point(double nx,double ny)
Double distance2d(D2point b)
Class name- D3point
Data members- double z
Member functions-
D3point()
D2point(double nz)
Double distance3d(D2point b)

Using inheritance calculate the distance. Write main() also.

Q11. A class number has been defined to find the frequency of each digit present in it and the sum of the
digits and to display the result.
Data members: long int num.
Member functions:
Void accept()
Void Digitfrequency()
Int sumdigit()
Also write the main() method.

Q.12 Write a class Employee to calculate the total salary


Data members- String name, int empcode double basicpay
Member fuctions:
Employee()
Void display()
Double salarycal(double pay)
Write main() to execute.

Q13. Class MyArray contains an array of integers.All the angles are given in
ascending order.
Class Name: MyArray
Data Member int arr[10]
Member functions;
Void read()
Int binary search()
Search the num in array using binary search technique >It returns ths subscript of array if element is found
else -999. Also write the main method.

Q14. Define a class string having data member char str[20],char str1[20] and peform string functions like
finding length, reversing the string and copying it .
Member functions:
Void accept()
Void findlength()
Void reverse()
Void copy()
Also write the main method for the above class.

Q15. Write a program to define a class student with the following data members int rollnumber[] ,float
percentage[]. The member functions are void accept for accepting roll no. and percentage and void asiign for
assigning the stream.
Also Write the main method() fort the above program.
96 or more Computer Science
>91 Electronic
>85 Mechanical
>80 Electrical
>75 Chemical
>70 civil

Q16. A class performance has been defined for finding out the mode and mode frequency.
You can make the assumption that class has 10 students.
IMPORTANT: You are not allowed to sort the marks.
Class Name: Performance
Data Members marks[]
Mode,freqatmode
Member Functions:
Performance()
Void readmarks()
Void getmode()
Void getfreqatode()

Q.17. A ticket is priced at Rs. 2.50, the booth keeps track of the number of people that have visited the
booth and that of the total amount money collected.
Define a class ticbooth including:
Data members- Number of people visited, Total amount collected
Member functions-
Constructor function assign initial values
To increment only people total in case ticket is not sold out
To increment people total as well as amount total if a ticket is sold out
To display the two totals
To display the number of tickets sold
Write main() to execute
Q18. A class twin prime is defined for checking and printing all twin prime numbers upto given limit.
Class name: TwinPrime
Data member: int a,b
Member Functions:
Void accept()
Void check()
Also write the main method for above program.

Q19. A class date is defined to calculate the number of days elapsed between any two dates.
Class name: date
Data members: int dd,mm,yy
Member functions:
Void accept()
Int numberofdays()
Also write the main method for above class.

Q20. Angle may be measured in degrees and minutes. Define a class angle for calculation and printing the
sum of two angles given.
Class Name: angle
Data member: int deg,min
Member Function:
Angle()
void accept()
anglesumangle(date,date)
Also write the main method for above class.

Вам также может понравиться