You are on page 1of 2

Computer Programming Lab External Exam Section: M3 Paper 1

1. Write a C++ program for finding the position of vowels in an array of characters. The array size and characters have
to be input by the user. (7)
2. Write an entire C++ program that reads a positive integer entered by an interactive user and then prints out all the
positive divisors of that integer in a column and in decreasing order. The program should allow the user to repeat
this process as many times as the user likes. Initially, the program should inform the user about how the program
will behave. Then the program should prompt the user for each integer that the user wishes to enter. The program
may be terminated in any of two ways. One way is to have the program halt if the user enters an integer that's
negative or zero. In this case the user should be reminded with each prompt that the program can be terminated in
that way. In this case, when the user accidentally enters a zero or negative integer to have its divisors calculated, the
program should inform the user that the input is unacceptable and should allow the user to try again (and again!).
Alternatively, after an integer has been entered and the divisors have been printed, the program can ask the user
whether he/she wishes to enter another integer.
Here is an illustration of how the program and the interactive user might interact. The user's responses to the
program are shown in bold italics.
This program is designed to exhibit the positive divisors of positive integers supplied by you. The program will repeatedly prompt you to
enter a positive integer. Each time you enter a positive integer, the program will print all the divisors of your integer in a column and in
decreasing order.
Please enter a positive integer: 6
6
3
2
1
Would you like to see the divisors of another integer (Y/N)? Y
Please enter a positive integer: -44
-44 is not a positive integer.
Please enter a positive integer: 0
0 is not a positive integer. (13)

Computer Programming Lab External Exam Section: M3 Paper 2

1. Write a program to print the following pattern using loops. (10)

+++++++
+++++
+++
++
+
2. Define a class candidate in C++ with following description:
Private Members:-
 A data member RNo (Registration Number) of type long
 A data member Name of type string
 A data member Score of type float
 A data member Remark of type string
 A member function AssignRem( ) to assign Remarks as per the Score obtained by a candidate. Score range
and the respective Remarks are shown as follows:
Score Remarks
>=50 Selected
< 50 Not selected

Public members:-
 A function ENTER( ) to allow user to enter values for RNo, Name, Score & call function AssignRem() to
assign the remarks.
 A function DISPLAY( ) to allow user to view the content of all the data members.
 A constructor to initialize all values to zero and name to “Preeti” (10)
Computer Programming Lab External Exam Section: M4 Paper 1
1. Define a class in base class student C++ with following description:
Private Members
• A data member admission number of type integer
• A data member name and grade of type string
• A data member Class and marks of type integer
• A data member percentage of type float
Public Members
• A member function CALPER() to calculate the PERCENTAGE from MARKS entered in 5 subjects

 A constructor to assign initial values as follows :-


NAME with the word “NULL”
CLASS as 0
PERCENTAGE as 0
MARKS IN ALL 5 SUBJECTS as 0
 A function FEEDINFO() to allow user to enter values for Admission number, class, name, array of marks in 5
subjects .

Define a derived class ASSIGN in C++ with the following description:-


Public Members
 A function CALGRA to call the function CALPER and calculate grade according to the percentage as follows:
Percentage Grade
More than 90 A
Between 80 to 90 B
Between 70 to 80 C
Between 60 to 70 D
Less than 60 E
 A function SHOWINFO() to allow user to view the content of all the data members. (12)

2. Write a C++ program to determine whether the input number is perfect or not. In number theory, a perfect number is
a positive integer that is equal to the sum of its proper positive divisors, that is, the sum of its positive divisors
excluding the number itself . (8)

Computer Programming Lab External Exam Section: M4 Paper 2


1. Assume that the bank maintains two accounts for the customers, one called as Savings account and the other as
Current account. The saving account provides compound interest and withdrawal facilities but not cheque book
facilities. The current account provides cheque book facilities and withdrawal but no interest. Current account
holders should maintain minimum balance and also if the balance falls below the minimum level, service charge
is imposed.
Create a class Account that stores customer name, account number and opening balance. From Account derive
classes Savings and Current to make them more specific to their requirements. Include necessary functions to
perform the following tasks:
i. Deposit an amount for customer and update the balance.
ii. Display the account details
iii. Compute the deposit interest
iv. Withdraw amount for a customer after checking balance and update the balance
v. Check the minimum balance. Impose penalty if required. Penalty= Rs. 100 per week.
Implement these without constructors. (15)

2. Print all the prime factors of a number input by the user. (5)

You might also like