List of Program Data Structure using C++ Lab (CAP1132)
List of Program Data Structure using C++ Lab (CAP1132)
1 Write a C++ program that calculates the sum of the digits in a given integer.
4 Write a C++ program that generates the first N terms of the Fibonacci sequence.
5 Write a C++ program that checks whether a given integer is a prime or not.
6 Write a C++ program to find the smallest element in an array and print its position.
8 Write a C++ program that checks whether a given string is palindrome or not.
11 Write a recursive C++ function to find the greatest common divisor of two integers.
Write a C++ program that swaps two integers by using a function which passes its
12
parameters by reference.
13 Create a class representing a “Book” with attributes like title, author, and price.
Implement:
Design a class “Rectangle” with private attributes length and width. Implement a friend
14
function to calculate the area of the rectangle.
15 Design a class “Person” with attributes “name” and “age”. Derive classes “Employee”
and “Student” from the base class “Person.” Implement functions to display details for
each class.
16 Define an abstract class “Shape” with a pure virtual function “calculateArea().” Derive
classes “Circle” and “Square” and implement the calculateArea() function.