CPP Assignment
CPP Assignment
Programming Assignment
C++Programming
Assignment – 1
TOPIC COVERED: Function in c ++
Address:-
Peth-Sangli road,Islampur.
Contact:- 8652844445
8693844446
DiSHA COMPUTER INSTITUTE, (Islampur)
Assignment –2
TOPIC COVERED: Classes and Object.
1. Create a class named item having two functions putdata() .getdata()will
accept values in class variables no& cost and putdata () will put the
values.
2. Create a class having three member function getdata() will accept values
in member variable.
3. Largest () which is going to retrieve largest integer and display () which
will display the largest to integers.
4. Create a friend function fact() that will accept object as parameter and
calculate factorial of number.
5. Create a function swap in a class which will swap two members entered.
6. Define a class to represent a bank account include the following
functions
Data members
Name of depositor
Account number
Type of account
Balance amount in the account.
Function
To assign initial values
To deposit
To withdraw an amount after checking balance.
To display name and balance.
DiSHA
COMPUTER INSTITUTE
An ISO 9001 : 2000 Certified
DiSHA COMPUTER INSTITUTE, (Islampur)
Assignment –3
TOPIC COVERED: Constructor & Destructor
1. Write a program to find Fibonacci series of the number entered by the
user. Initialize the value in the parameterized constructor.
2. Write a program to find the function of a given using constructor.
3. Write a program to accept the value of the name of an employee & its
salary using a constructor and print the value of the using display ().
4. Write a program to accept two numbers in the constructor of the class
and create functions sum(),diff(), mul(),div(), which will calculate sum,
difference, product & quotient of number.
5. Write a program to implement overloaded constructor with the name
x,x must be empty constructer and x and must be a parameterized
constructor & it must also be a copy constructor.
6. Write a program to create a class fib with overloaded that will initialize
the value of n i.e. number until which we need to find Fibonacci series.
7. Write a program to accept the name, rollno & makes of a student in
constructor & calculate its average in the function avg() and print the
message whether the student has passed or failed the criteria for
student to pass or fail is avg>35 pass avg<35 fail
Address:-
Assignment –4
DiSHA
COMPUTER INSTITUTE
TOPIC COVERED: Inheritance An ISO 9001 : 2000 Certified
2. Create a class student that will have protected variable getnumber (int).
this function will accept the roll number of student. Create another class
test that will publically inherit student class. This class contains marks in
getmarks () function. Finally there is another class result which display
the total by calculating it & printing. The display function should also
print the roll number accepted in student class. The result class will
inherit the class the class test publicly.
Student
Test
Result
Bank
Deposit Withdrawal
DiSHA COMPUTER INSTITUTE, (Islampur)
Staff
Code, Name
Address:-
Contact:- 8652844445
8693844446
DiSHA COMPUTER INSTITUTE, (Islampur)
Assignment –5
TOPIC COVERED: Polymorphism
1. Write a program to swap (2,3) (4,5) numbers using function overloading.
Give the name of the function as swap.
2. Create the overloaded function sum, one is having two int parameters &
one is having five int parameters.
3. Create a base class shape. Use this class to store to double types values
that could be used to compute the area of figures. There are two specific
classes called triangle & rectangle which are derived form base class shap.
Base class contains one member function display_area()as a virtual
function & redefine this function in deriveclasses to suite their
requirement.
4. Create a class space having three variables x,y,&,z. the class has two
functions getdata () having three int parameters & display () which display
the variables. It also contains overloaded unary operator-() that will covert
the member form negative to positive as required.
5. Create a program using overloading that will and, subtract, multiply &
divide the complete numbers ( using binary overloading )
6. Create a class to implement binary operator +, that will concatenate two
strings when involved.
7. Consider a book shop which sells bolt books & videotapes .Create a class
known as media that stores title & price of book. A display () is used in all
the classes to display the class content. Implement the program using
virtual pointer. initialize the values in the sub class & base class using base
class using base constructor.
DiSHA
COMPUTER INSTITUTE
An ISO 9001 : 2000 Certified
DiSHA COMPUTER INSTITUTE, (Islampur)
Assignment -6
Topic covered: file handling
1. Write a program that will print all the even numbers & odd numbers
between the range of 1 to 20 different files.
4. Write a program that will read data form the file & print it on the user
screen.
Address:-
DiSHA
Disha computer institute, COMPUTER INSTITUTE
An ISO 9001 : 2000 Certified
Near mankeshware theater,
Peth-Sangli road,Islampur.
Contact:- 8652844445,8693844446