BCAAA 4th Sem Practical List C++
BCAAA 4th Sem Practical List C++
Q 1. C++ program to print ASCII value of a character and convert lowercase to uppercase and vice versa.
Q 2. Create a class to get and print the details of a student.
Q 3. Raising a number n to a power p is the same as multiplying n by itself p times. Write a function called
power ( ) that takes a double value for n and an int value for p, and returns the result as a double value.
Use a default argument of 2 for p, so that if this argument is omitted, the number will be squared. Write a
main ( ) function that gets values from the user to test this function.
Q 4. Create two classes DM and DB which store the value of distances. DM stores distances in meters and
centimeters and DB in feet and inches. Write a program that can read values for the class objects and add
one object of DM with another object of DB. Use a friend function to carry out the addition operation.
The object that stores the results may be a DM object or DB object, depending on the units in which the
results are required. The display should be in the format of feet and inches or meters and centimeters
depending on the object on display.
Q 5. Create a class rational which represents a numerical value by two double values- NUMERATOR &
DENOMINATOR. Include the following public member Functions:
• constructor with no arguments (default).
• constructor with two arguments.
• void reduce( ) that reduces the rational number by eliminating the highest common factor between
the numerator and denominator.
• Overload + operator to add two rational number.
• Overload >> operator to enable input through cin.
• Overload << operator to enable output through cout.
Write a main ( ) to test all the functions in the class.
Q 6. A hospital wants to create a database regarding its indoor patients. The information to store include
a) Name of the patient b) Date of admission c) Disease d) Date of discharge
Create a structure to store the date (year, month and date as its members). Create a base class to store the
above information. The member function should include functions to enter information and display a list
of all the patients in the database. Create a derived class to store the age of the patients. List the
information about all the to store the age of the patients. List the information about all the pediatric
patients (less than twelve years in age).
Q 7. Write a program to implement multiple inheritance.
Q 8. Write a program to access a function with the help of pointer.
Q 9. Make a class Employee with a name and salary. Make a class Manager inherit from Employee. Add an
instance variable, named department, of type string. Supply a method to toString that prints the
manager’s name, department and salary. Make a class Executive inherit from Manager. Supply a method
to String that prints the string “Executive” followed by the information stored in the Manager
superclass object. Supply a test program that tests these classes and methods.
Q 10. Imagine a tollbooth with a class called toll Booth. The two data items are a type unsigned int to hold the
total number of cars, and a type double to hold the total amount of money collected. A constructor
initializes both these to 0. A member function called payingCar ( ) increments the car total and adds 0.50
to the cash total. Another function, called nopayCar ( ), increments the car total but adds nothing to the
cash total. Finally, a member function called displays the two totals. Include a program to test this class.
This program should allow the user to push one key to count a paying car, and another to count a
nonpaying car. Pushing the ESC kay should cause the program to print out the total cars and total cash
and then exit.
Q 11. Write a function called reversit ( ) that reverses a string (an array of char). Use a for loop that swaps the
first and last characters, then the second and next to last characters and so on. The string should be passed
to reversit ( ) as an argument. Write a program to exercise reversit ( ). The program should get a string
from the user, call reversit ( ), and print out the result. Use an input method that allows embedded blanks.
Test the program with Napoleon’s famous phrase, “Able was I ere I saw Elba)”.
Q 12. Program to write and read an object in, from a binary file using write() and read() in C++
Q 13. Write a program to implement abstract class and Virtual function.
Q 14. C++ Program to implement Stack in STL, Vector in STL
Q 15. Write a program to demonstrate exception handing using try, catch and throw.
Q 16. Design the following static web pages required for an online book store web site.
1) HOME PAGE: The static home page must contain three frames.
Top frame : Logo and the college name and links to Home page, Login page, Registration page,
Catalogue page and Cart page (the description of these pages will be given below). Left frame :
At least four links for navigation, which will display the catalogue of respective links. For e.g.:
When you click the link “CSE” the catalogue for CSE Books should be displayed in the Right
frame. Right frame: The pages to the links in the left frame must be loaded here. Initially this
page contains description of the web site.
2) LOGIN PAGE: This page looks like below:
Logo Web Site Name Home Login Registration Catalogue Cart CSE ECE EEE CIVIL
3) CATOLOGUE PAGE: The catalogue page should contain the details of all the books available in
the web site in a table.
The details should contain the following: 1. Snap shot of Cover Page. 2. Author Name. 3.
Publisher. 4. Price. 5. Add to cart button.
Q 17. Write HTML code to create following table