C++ Programming Assigment of OUSL
C++ Programming Assigment of OUSL
Q2.
Write a complete C++ program introducing functions for each task listed below. You are
supposed to use arguments passed by value technique in order to write the program.
Page 1 of 3
i.
ii.
iii.
iv.
To input a sentence with more than 20 characters and less than 100 characters.
To replace each first letter character (given in lower case) of a word to upper case
in any given sentence and display the new sentence.
To count the number of characters in the string and display the count.
To find whether any word in the sentence occurs multiple times. If so display Yes
and if not No.
Q3.
Write a complete C/C++ program to implement a simple calculator with following menu and
execute different functions depending on the user selection. The calculator should perform
Addition( + ), Subtraction ( - ), Multiplication (*), Division (/ ) and find Modulus(%) of two
numbers.
1.
2.
3.
4.
5.
6.
7.
8.
9.
Use a pointer to call different functions depending on the option that the user has entered.
If the user selects Option no 2 or 3 or 4 or 5 or 6 without selecting Option no 1 the user
should be prompt with a message asking him/her to select Option no 1 first. The user
should always enter an integer value for the option selection, if not the user should be
prompt with another message asking for proper input for selection.
You may write your own assumptions you made when building the program considering
the functionalities that the program need to execute.
Q4.
Write a complete C++ program to calculate the volume of a cube, cylinder and a cuboid. Use
function overloading technique in order to write the program.
NOTE:- Formulas necessary to find the volume are as follows
Volume of a cube = s s s =s3
r r h r 2 h
Volume of a cylinder =
=
l b h lbh
Volume of a cuboid =
=
Where s Length of a side of the cube
r - Radius of the base of the cylinder
Page 2 of 3
- 3.14519
Q5. Define a class in C++ to represent a bank account. Use constructors and destructors as
applicable. Include the following as data members
Name of the depositor
Account number
Type of account
Balance amount in the account
You are supposed to write member functions for the following tasks.
To deposit an amount
To withdraw an amount after checking the balance
To display name and the balance
You may use the following data given on TableQ5 for the program.
Account number
Type of account
Balance(Rs.)
Kamala
Raja
Nelum
1010890
2020980
3030089
Savings
Savings
Savings
150000.00
60000.00
140000.00
Table Q5
Bank Transactions that needs to program are
Kamala withdraws an amount of Rs.110000.00 from his account
Raja Deposits(Save money) Rs. 3000.00 on his account
Nelum Checks his account balance
Write a main program which can be used to test your program.
Note: You should use object oriented concepts to develop the program.
- END -
Page 3 of 3