[go: up one dir, main page]

0% found this document useful (0 votes)
263 views2 pages

C++ Programs

The document outlines several C++ programming exercises: 1) Create a stack class with push(), pop(), and overflow/underflow checks. Create a file class to display a file with line numbers. 2) Create an arithmetic class with addition, subtraction, multiplication, and division functions. Create a shape class with area and perimeter virtual functions for square, rectangle, and triangle classes. 3) Read an integer and sum its digits until single digit using constructors, destructors, and inline functions. Check if a string is a palindrome using pointers. 4) Overload arithmetic operators for a float class. Overload functions to sum matrices of different data types. 5) Create a string class with initialization,

Uploaded by

baby
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)
263 views2 pages

C++ Programs

The document outlines several C++ programming exercises: 1) Create a stack class with push(), pop(), and overflow/underflow checks. Create a file class to display a file with line numbers. 2) Create an arithmetic class with addition, subtraction, multiplication, and division functions. Create a shape class with area and perimeter virtual functions for square, rectangle, and triangle classes. 3) Read an integer and sum its digits until single digit using constructors, destructors, and inline functions. Check if a string is a palindrome using pointers. 4) Overload arithmetic operators for a float class. Overload functions to sum matrices of different data types. 5) Create a string class with initialization,

Uploaded by

baby
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/ 2

1. a) Write a C++ Program to create a class to implement the data structure STACK.

Write a

constructor to initialize the TOP of the STACK. Write a member function PUSH() to

insert an element and member function POP() to delete an element check for overflow

and underflow conditions.

b) Write a C++ Program to create a File and to display the contents of that file with line

numbers.

2. a) Write a C++ Program to create a class ARITHMETIC which consists of a FLOAT and an

INTEGER variable. Write member functions ADD (),SUB(), MUL(), DIV() to perform

addition, subtraction, multiplication, division respectively. Write a member function to

get and display values.

b) Write a C++ Program to create a class SHAPE which consists of two VIRTUAL

FUNCTIONS Calculate_Area() and Calculate_Perimeter() to calculate area and perimeter

of various figures. Derive three classes SQUARE, RECTANGLE, TRIANGE from class

Shape and Calculate Area and Perimeter of each class separately and display the result.

3. a) Write a C++ Program to read an integer number and find the sum of all the digits until it

reduces to a single digit using constructors, destructors and inline member functions.

b) Write a C++ Program to check whether the given string is a palindrome or not using

Pointers.

4. a) Write a C++ Program to create a class FLOAT that contains one float data member.

Overload all the four Arithmetic operators so that they operate on the object FLOAT.

b) Write a C++ Program using Function Overloading to read two Matrices of different Data

Types such as integers and floating point numbers. Find out the sum of the above two

matrices separately and display the sum of these arrays individually.

5. Write a C++ Program to create a class STRING. Write a Member Function to initialize,

get and display stings. Overload the operators ++ and == to concatenate two Strings and

to compare two strings respectively.

b) Write a C++ Program to create two classes each class consists of two private variables, a
integer and a float variable. Write member functions to get and display them. Write a

FRIEND Function common to both classes, which takes the object of above two classes

as arguments and the integer and float values of both objects separately and display the

result.

6. a) Write a C++ Program to create class, which consists of EMPLOYEE Detail like

E_Number, E_Name, Department, Basic, Salary, Grade. Write a member function to get

and display them. Derive a class PAY from the above class and write a member function

to calculate DA, HRA and PF depending on the grade.

b) Write a C++ Program to merge two files into a single file.

You might also like