Sri Guru Gobind Singh College of
Commerce
Programming using C++
2342011204
Submitted By:- Anvi Bansal 254018
Submitted To:- Dr. Vandana Kalra
Assistant Professor
Department of Computer Science
SGGSCC
[Link] Date Title Pg. No.
1 19/01/26 Question 1 3
2 22/01/26 Question 2 4
3 09/02/26 Question 3 5
4 09/02/26 Question 4 6-9
5 22/01/26 Question 5 10
6 09/02/26 Question 6 11
7 22/01/26 Question 7 12-13
8 02/02/26 Question 8 14-16
9 25/02/26 Question 9 17-18
10 09/02/26 Question 10 19
11 03/03/26 Question 11 20-21
12 03/03/26 Question 12 22
1. Write a program to compute the sum of the first n terms of the following
series:
S = 1 − ½^2 +⅓^3 - …..1/n^n
The number of terms n is to be taken from the user through the command
line. If the
command line argument is not found then prompt the user to enter the
value of n.
CODE:
OUTPUT
2. Write a program to remove the duplicates from an array.
CODE:
OUTPUT:
3. Write a program that prints a table indicating the number of occurrences
of each alphabet in the text entered as command line arguments.
CODE:
OUTPUT:
4. Write a menu driven program to perform string manipulation (without
using inbuilt string
functions):
a. Show address of each character in string
b. Concatenate two strings.
c. Compare two strings
d. Calculate length of the string (use pointers)
e. Convert all lowercase characters to uppercase
f. Reverse the string
g. Insert a string in another string at a user specified position
CODE:
OUTPUT:
5. Write a program to merge two ordered arrays to get a single ordered
array.
CODE:
OUTPUT:
6. Write a program to search a given element in a set of N numbers using
Binary Search
a. with recursion
b. without recursion.
CODE:
OUTPUT:
7. Write a program to calculate GCD of two numbers
a. with recursion
CODE:
OUTPUT:
b. without recursion.
CODE:
OUTPUT:
8. Create a Matrix class. Write a menu-driven program to perform following
Matrix
operations (exceptions should be thrown by the functions if matrices
passed to them are
incompatible and handled by the main() function):
a. Sum
b. Product
c. Transpose
CODE:
OUTPUT:
9. Define a class Person having name as a data member. Inherit two
classes Student and
Employee from Person. Student has additional attributes as course, marks
and year and
Employee has department and salary. Write display() method in all the
three classes to
display the corresponding attributes. Provide the necessary methods to
show runtime
Polymorphism.
CODE:
OUTPUT:
10. Create a Triangle class. Add exception handling statements to ensure
the following conditions: all sides are greater than 0 and sum of any two
sides is greater than the third side. The class should also have overloaded
functions for calculating the area of a right angled triangle as well as using
Heron's formula to calculate the area of any type of Triangle.
CODE:
OUTPUT:
11. Create a class Student containing fields for Roll No., Name, Class, Year
and Total Marks.
Write a program to store 5 objects of Student class in a file. Retrieve these
records from the file and display them.
CODE:
OUTPUT:
12. Copy the contents of one text file to another file, after removing all
whitespaces.
CODE:
OUTPUT: