Professional Documents
Culture Documents
Assignement of Advanced Programming Huye 202022
Assignement of Advanced Programming Huye 202022
Question 1.
Data members:
name(string type),
calc_average() to calculate the average note and disp() to display the name and average
mark
Then write a program that uses the above class to create an array of 5 students. The program asks the
user to enter the name and marks of each student from the keyboard and then displays the name and
average mark of each student on different lines [6]
Question 2.
Define a class BOOK with the following specifications :
Private members of the class BOOK are
BOOK NO integer type
BOOKTITLE 20 characters
PRICE float (price per copy)
TOTAL_COST() A function to calculate the total cost for N number of copies where N is passed to the
function as argument.
Public members of the class BOOK are
INPUT() function to read BOOK_NO. BOOKTITLE, PRICE
PURCHASE() function to ask the user to input the number of copies to be purchased. It invokes
TOTAL_COST() and prints the total cost to be paid by the user.
Question 3.
Write a Program which allows the user to input an integer value for a variable name Limit [2].
Based on the input value, the program should perform the following tasks:
• Check whether the value entered by the user falls within the range from 10 to 150. (10 and
150 included in the given range.) [2]
Display those numbers which are divisible by both 3 and 5 in the range from 1 up to the Limit.
[2]
Calculate and display the sum of those numbers which are divisible by either 3 or 5. [3]
Final task will be to count and display those numbers which are not divisible by 3 or5. [3]
Question 4.
Write a recursive function that computes and returns the sum of all elements in an
array, where the array and its size are given as parameters.