C++ Lab Manual
C++ Lab Manual
C++ Programming
GENERAL GUIDELINES
You should attempt all problems/assignments
given in the list session wise.
You may seek assistance in doing the lab
exercises from the concerned lab instructor. Since
the assignments have credits, the lab instructor is
obviously not expected to tell you how to solve
these, but you may ask questions concerning the
programming language or a technical problem.
For each program you should add comments
above each part of your program. This should
also include a description of the function written,
the purpose of the function, meaning of the
argument used in the function and the meaning
of the return value (if any).
The program should be interactive, general and
properly documented with real Input/ Output
data.
It is your responsibility to create a separate
directory to store all the programs, so that
nobody else can read or copy.
The list of programs (session-wise) is available to
you in this lab manual.
You should utilize the lab hours for executing the
programs, testing for various desired outputs
and enhancements of the programs.
As soon as you have finished a lab exercise,
contact one of the lab instructor/ in-charge in
order to get the exercise evaluated and also get
the signature from him/her on the Lab Manual
Report.
Each lab session will be for 1 hour
LAB MANUAL REPORT
10
11
12
13
14
15
16
17
18
19
20
21
22
SESSION-1
SESSION-2
4. Write a program to input any number after that check number is Armstrong or
not.
5. Write a program to find nCr using function with parameter and return value.
6. Write a program to calculate the compound interest using the formula A = P ×
(1 + r/100)n.
SESSION-3
SESSION-4
10. Write a program for printing a table of a given number using function with
parameter and no return value.
11. Write a program for ex=1+x+x2+x3+x4+∙∙∙+xn using function with parameters
and return type.
12. Write a program to find the sum of square of first n even natural numbers
using function without parameter but with return type
SESSION-5
13. Write a program to find the greatest number amongst three given numbers by
using function with parameters and return value
14. Write a program to search an element in the given two-dimensional array
using function
15. Write a program to search and display the position of an element in a single-
dimensional array using function.
SESSION-6
16. Write a program to find the sum of diagonal elements, upper triangular
elements and the lower triangular elements.
17. Write a program to check whether the given matrix is orthogonal or not. Use
the formula A × AT = I.
18. Write a program to multiply two matrices if multiplication is possible.
SESSION-7
22. Write a program to count the number of characters, number of words in the
string and to check whether the given string is palindrome or not.
23. Write a program to reverse the string.
24. Write a program for addition of two matrices and to find the transpose of the
resultant matrix.
SESSION-9
25. Write a menu-driven program to add, subtract, multiply and divide complex
numbers
26. Write a menu-driven program to perform the following operations on the
account of a particular customer according to account number. The account
details for various customers are already initialized:
(a) To deposit money.
(b) To withdraw money after checking minimum balance.
(c) To display the information the customer.
Signature of Instructor Date
/ /
SESSION-11
27. Write a menu-driven program to read distances in meter and centimeter, add
and subtract two distances using structure and functions.
28. Declare structure to represent student with the following data: Rollno, Name,
Branch, Date of birth, Admission date, City, Father’s occupation. Write a
program to find all those students whose father is a doctor.
SESSION-12
29. Write a program to print the bill details of 10 customers with the following
data: Meter number, customer name, no. of SESSIONs consumed, bill date,
last date to deposit and the city name. The bill is to be calculated according to
the following conditions:
No. of SESSIONsChargeFor first 100 SESSIONsRs 0.75 per SESSIONFor
the next 200 SESSIONsRs 1.80For the next 300 SESSIONsRs 2.75
30. Write a program to find the smallest and largest element of an array.
SESSION-13
31. Write a program to read and display the following details of employees using
pointers: ename, designation, age, dob (dd/mm/yyyy).
32. Write a program for the addition of two time values given in hh:mm:ss format
using the friend function.
SESSION-14
33. Write a menu-driven program for addition, subtraction, display result of two
distances (given in meter and centimeter) using member functions and friend
function.
34. Write a menu-driven program for deposition, withdrawal and display balance
for the bank account of a particular customer.
Signature of Instructor Date
/ /
SESSION-15
35. Generate a result sheet for all students who have secured honors in CSE
branch with the following details
(a) Roll number
(b) Name
(c) Semester
(d) Branch
(e) Institute
(f) Marks in different subjects
(g) Grade
36. Write a program in C++ that prints the factorial of a given number using a
constructor and a destructor member function.
SESSION-16
37. Write a program in C++ that prints the Fibonacci series using parameterized
constructor and a destructor member function.
38. Develop a reservation system in C++ with the following data:
(a) Train number
(b) Train name•
(c) Source
(d) Destination
(e) Journey date
(f) Total amount
(g) Category (Sleeper, AC-1, AC-2, AC-3)
(h) Passenger’s name
(i) Passenger’s age
SESSION-17
39. Develop a mark sheet in C++ for the university examination with the following
data:
(a) Students’ name•
(b) Enrollment number
(c) Roll number
(d) Theory marks in five subjects
(e) Practical marks in five subjects
(f) Sessional marks in five subjects
(g) Grade
Use any form of constructors to develop the system.
40. Develop a library information system in C++ with the base class named
“author” containing following information:
• ISBN no.
• Title of the book
• Author’s name
and the derived class named “pubdetails” which contains the following
information:
• Publisher’s name
• Year of publication
• Price of the book
Define functions to create the database and retrieve individual information as
and when required.
SESSION-18
SESSION-19
43. Write a program to carry out the sum, difference, multiplication and division of
rational numbers using operator overloading through member function.
44. Write a program to concatenate two strings “Department of Computer Science
and Engineering” and “ABC Institute of Science and Technology Bhopal”
using operator overloading through friend function.
SESSION-20
45. Write a program to concatenate two strings “Prof Rajesh K Shukla” and
“Computer Science & Engineering” using operator overloading through
member function and without using constructors.
46. Write a program using virtual function to find the area of circle, area of
rectangle and area of triangle.
SESSION-21
47. Write a program to calculate the sum and find the greatest element in the list
using member function of a class as a template function.
48. Write a program to calculate the sum and the smallest element in the list, and
to check whether the given number is present in the list and the number of
times of the occurrence of that number using member function of a class as a
template function.
49. Write a program to read an array of any type of any size using non-type
arguments in a template.•
50. Write a program to read and write students information into the file using the
data members in a private access mode.
SESSION-23
51. Program to read and write the employees’ information, that is, name,
designation, salary and phone numbers using class and the read() and write()
functions with files.
52. Write a menu-driven program to append, display, modify students information
(rollno, age, phnum and height) in the file.
SESSION-24
53. Write a menu-driven program to append, modify, display all, display current
students’ information (rollno, name, branch, semester, address, email) in the
file using class.
54. Write a menu-driven program to append, display current, display all, search
and delete students’ information from the file.
SESSION-25
55. Write a program to read a string using the getline() function and display how
many times the particular character appears in the string.
56. Write a program to read a string using the getline() function and count the
number of vowels in the string.
Student Name:
DATE: _________________________________
SIGNATURE:___________________________