0% found this document useful (0 votes)
3 views

Index CPP

The document outlines a series of programming tasks in C++ that cover various concepts such as input/output operations, control structures, classes, and object-oriented programming. Each task specifies a unique problem to solve, ranging from basic arithmetic operations to complex data management using classes. The tasks are designed to enhance programming skills and understanding of C++ through practical implementation.

Uploaded by

sg4861795
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Index CPP

The document outlines a series of programming tasks in C++ that cover various concepts such as input/output operations, control structures, classes, and object-oriented programming. Each task specifies a unique problem to solve, ranging from basic arithmetic operations to complex data management using classes. The tasks are designed to enhance programming skills and understanding of C++ through practical implementation.

Uploaded by

sg4861795
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

S.

Aim of Experiments Grade Signature


No.
1 Write a C++ program that reads five integers from the user, calculates their sum
and average, and then prints the results. Your program should be able to handle
any integer values provided by the user.
2 Write a C++ program that reads an integer and determines whether it is a prime
number and whether it is an even number. The program should output two lines:
 The first line should indicate whether the number is prime (1 for prime, 0 for
not prime).
 The second line should indicate whether the number is even (1 for
even, 0 for odd).
3 Write a C++ program that determines whether a given year is a leap year or not.
4 Write a C++ program to compute the simple interest given the principal amount,
the rate of interest, and the time period. The program should print the
simple interest.
5 Write a C++ program to determine the largest of three given numbers. The
program should print the largest number
6 Write a C++ program to find the roots of a quadratic equation of the form ax^2
base .The program should compute the roots based on the determinant and print
the roots with correct accuracy.
7 Write a C++ program that takes an integer input between 1 and 7 (inclusive)
representing a day of the week, and prints the corresponding day name. If the
input is outside this range, the program should print "Invalid".
8 White a C++ program to compute the factorial of a non-negative integer using for
loop. The program should handle non-negative integers and compute the factorial
without unnecessary print statements.
9 Write a C++ program that takes an upper limit as input from the user and prints
all prime numbers be taken 1 and that upper limit. A prime number is a positive
integer greater than 1 that has no positive integer divisors other than 1 and itself.
10 Write a C++ program to generate and print the Fibonacci series up to a given
number n using a while loop. The Fibonacci series is a sequence of numbers
where each number is the sum of the two preceding ones, typically
starting with 0 and 1.
11 Write a program in C++ to print even and odd numbers between 1 and 100 using
a do-while loop. The maximum number up to which numbers are printed will be
given by the user.
12 Write a C++ program to perform basic bank operations using a class. The
program should allow the user to:
 Create a new account
 Deposit money into the account.
 Withdraw money from the account
 Check the balance of the account.
 Exit: Terminate the program
13 Write a C program to calculate and print the electric bill for multiple customers.
The program should use a class Electric to handle customer details and calculate
the bill based on the number of units consumed. The bill calculation is as follows:
For units between 100 and 300 (exclusive of 100 but inclusive of 300)
 Base Charge 500
 Plate: 0.40 per unit for units above 100 (including 300).
For units between 301 and 500 (inclusive of 301 and 500)
 Base Charge: 500
 Plate: 040 per unit for the first 200 units (tom 101 to 300) +0.50 per unit for
units from 301 to 500.
For units above 500
 Base Charge: 500
 Plate 0.00 per unt for all units above 500).
An additional surcharge of 15% is added the bill exceeds 250.
14 Write a C++ program to sort an array using overloaded sort functions. The
program should support sorting arrays of integers, floating-point
numbers, and characters.
15 Write a C++ program to represent a vector using a class. The class should support
the following functionalities:
 Create the Vector: Initialize the vector with a given size and values.
 Multiply by a Scalar: Multiply each element of the vector by a scalar value.
 Modify Element: Update the value of a specific element in the vector,
 Element-wise Multiplication: Multiply two vectors element-wise and store
the result in a new vector.
16 Write a program that performs the following tasks:
Start: Prompt the user to start the program by entering 1.
Print Numbers: The program should print numbers sequentially starting from 1.
Continue or Stop: After printing each number, ask the user if they want to
continue or stop.
Handle Stop:
 If the user opts to stop (n), prompt for the "Destructor" input (0 or 1)
 If O is entered, print the total count in seconds
 If 1 is entered, print the total count and also a message indicating the
destructor is called again upon destructor call.
17 A bookshop maintains an inventory of books available for sale. Each book in the
inventory includes the following details:
 Author
 The
 Price
 Publisher
 Stock Position
The system should perform the following tasks:
Search for a Book:
 When a customer requests a book, the salesperson inputs the title and author
of the book.
 The system searches the inventory for the book based on the provided the and
author
Check Availability:
If the book is not found in the inventory, the system should display an appropriate
message indicating that the book is not available
Handle Bock Requests:
 If the book is found, the system displays the book details and prompts for the
number of copies required by the customer.
 If the requested number of copies is available in stock, the system calculates
and displays the total cost of the requested copies.
 If the requested number of copies exceeds the available stock, the system
displays the message "required copies not in stock".
18 Create a class named Box that represents a box with three dimensions: length,
width, and height. The constructor of the class should accept three double values,
each representing one side of the box. Implement a member function named vol()
that computes and returns the volume of the box. The vol() function should be
used to display the volume of each box object.
19 Write a C++ program that defines a String Op class to manage dynamic strings.
Implement the following features:
 A constructor to initialize the string
 A copy constructor.
 A destructor to free allocated memory.
 Overload the operator to compare two String objects.
 A function to display the string.

20 Define a class named String that represents a string. Overload the operator to
concatenate two String objects.
21 Write a C++ program to manage patient information in a hospital. Impermeant a
class. Patient that stores the patient's name. The class should include :
 A constructor to initialize the patient's name
 A member function to input patient information.
 A member function to display patient details.
22 A hospital wants to create a database for its indoor patients. The information to
store includes:
 Patient's name
 Date of birth (year, month, and day).
23 Write a C++ program to read city names from a user-specified file and display only
those names that begin with the characters "B" or "C".
24 White a C++ program that takes two objects of the type Complex Number and
returns an object of the same type that represents the sum of the two complex
numbers. The Complex Number class should include:
 Constructor to initialize the real and imaginary parts.
 An overloaded operator to add two complex numbers
 A function to display the complex number.
25 Write a C++ program that converts:
 A decimal integer to binary.
 An integer or a decimal number to hexadecimal.
26 Create a class called Student to manage student information. The class should
contain data members for the student's roll number, name, and age, implement
exception handling to ensure that if negative values are entered for the roll number
or age, an exception is thrown.
27 You are developing a program to manage complex numbers, where each complex
number is represented by a class. To ensure correct copying of complex numbers,
you need to overload the assignment (=) operator for the Complex class
Write a C++ program to overload the assignment operator (=) to assign one
Complex number object to another.
28 Write a C++ program to evaluate A B 3, where A and B are objects of the same
class, Implement the multiplication operator (*) to multiply a Number object by an
integer, and the assignment operator (=) to assign the result to
another Number object.
29 Write a C++ program to calculate the salary of a medical representative based on
their sales. The bonus and incentives to be offered are based on the total sales. If
sales exceed Rs. 1,50,000, use a specific set of parameters, otherwise, use a
different set. Implement a conditional constructor and destructor to handle the
calculation of salary and bonus.The program divides the medical representative's
salary and bonus calculation into two sets based on the sales amount
Sales Exceeding Rs. 150,000:
 Base Salary Rs. 30,000
 Bonus 10% of the sales amount
Sales Rs. 150,000 or Less:
 Base Salary Rs. 20,000
 Bonus: 5% of the sales amount.
30 Write a C++ program to calculate the earnings of a newspaper delivery boy based
on the type of delivery round and the number of rounds done in a week. A delivery
boy earns Rs. 2 for each morning delivery and Rs. 1.50 for each evening delivery.
The boy is paid for either morning or evening deliveries, but not both. Implement a
class with a conditional constructor and destructor to compute and display
the total earnings.
31 You are required to implement a simple application using object-oriented
programming in C++ Define three classes: A, B, and C. The class C is derived
from both A and B. Each class should have a count() member function that is
declared as virtual. Implement the functionality to:
 Create objects of type A, B, and C.
 Display the current count of objects of each type
Allow the user to interactively create objects and view the counts.
The counts should be maintained such that:
 Class A maintains the count of its own objects
 Class B maintains the count of its own objects.
 Class C maintains the count of its own objects.
32 Write a C++ program that defines a class NameList with a private member to store
an array of ten names.The class should include public member functions to input
ten names from the user, sort these names in descending order, and display them.
In the main function, create an object of the NameList class and use to input the
names, sort them, and then display the sorted names.
33 Write a C++ program that defines a base class Base and several derived classes.
The program should prompt the user to enter a number between 0 and 5.
Depending on the number provided, the program should create an instance of the
corresponding class (either Base or one of the derived classes) and invoke the
show() method of that class using a pointer to the base class.
0: Create an instance of Base
1: Create an instance of Derived 1.
2: Create an instance of Derived2.
3. Create an instance of Derived3.
4: Create an instance of Derived4.
5. Create an instance of Derived5.
34 Write a C++ program that reads input from the user line by line. The input consists
of alternating strings and integers. The program should display the input in two
columns, with strings in the first column and integers in the second column. If
there are more strings than integers, print "EMPTY" in the integer column for the
extra strings, and if there are more integers than strings, print "EMPTY" in the
string column for the extra integers.

You might also like