Showing posts with the label CPP

Write a c++ program to read a text file and count number of vowels.

#include<fstream.h> #include<iostream.h> #include<ctype.h>…

Create a class Distance containing Feet and Inches as data members. Write a C++ program to read distance from user, store it in the file and to read it from the file and display it to the user. Use operator overloading for the following: 1. << to write distance object in inches format to a file 2. >> to read inches from File.

#include<iostream.h> #include<fstream.h> #include<conio.h>…

Write a menu driven C++ program using class to calculate Area and Volume of rectangle using inline function.

#include<iostream.h> #include<conio.h> class Rectangle {   i…

Create a class MyFile containing: - FILE *fp; - Char fn[maxsize]; Write necessary member Functions using operator overloading: 1. + F3=F1+F2 Put contents of F1 and F2 in F3. 2. - -F3 Changes the case of all upper and lower case characters in F3.

#include<iostream.h> #include<fstream.h> #include<string.h&g…

Consider the following Class mystring { char str [100]; Public: // methods }; Overload operator “!” to reverse the case of each alphabet in the string.

#include<iostream.h> #include<string.h> #include<ctype.h> …

Create a class currency containing rupees and paise as data members. Write necessary member functions using operator overloading for the following: 1. currency (long int rup=0,int paise=0) 2. currency & operator += (currency &) (to add one currency to another) 3. currency & operator - = (currency &) (to subtract one currency from another) Accept Rupee & paise from user and display it.

#include<iostream.h> #include<conio.h> class currency {   lo…

Create a C++ class for a student object with the following attributes—roll no, name, number of subjects , marks of subjects. The number of subjects varies for each student. Write a parameterized constructor which initializes roll number, name and number of subject and creates the array for marks dynamically, write member function for accepting marks and display all information of student.

#include<iostream.h> #include<string.h> #include<conio.h>…

Write a C++ program to find area of triangle, circle, and rectangle using function overloading.

#include<iostream.h> #include<conio.h> void area(int r) {   …

Consider a class point containing x and y coordinates. Write necessary functions for the following cases: 1. to accept a point 2. to display it 3. to find distance between two points using operator overloading (-) (Use friend function)

#include<iostream.h> #include<conio.h> class point {   int x…

Write a program to read the contents from the file “sample.txt”. Store all the characters from “sample.txt” into the file “character.txt” & store all digits into the file “digit.txt

#include<fstream.h> #include<ctype.h> #include<conio.h> …

Write a C++ program which will find the maximum of 3 integer numbers and maximum of 3 float numbers using function overloading.

#include<iostream.h> #include<conio.h> void max(int a,int b,in…

Create a class Student having data members: - RollNo - Name - Marks Write necessary member functions : 1. to accept the details and store it into the file “school.dat” 2. to read the details from file and display it. 3. to update a given record into the file.

#include<iostream.h> #include<process.h> #include<fstream.h…

Create a class Medicalshopee containing - medicine - qty - price Medicine details are stored into the file “medical.txt” .When any medicine has to be sold, it is first searched into the file, if found, the qty is decremented by that much qty to be sold.

#include<conio.h> #include<stdio.h> #include<string.h> #…

Consider a class Complex Class Complex { float real; float imaginary; Public: //methods; }; Overload operator ‘+’ to add two objects of that class use parameterized constructor for accepting values of complex numbers.

#include<iostream.h> #include<conio.h> class Complex {   flo…

Design two base classes Personnel (name, address, email-id, birth date) and Academic (marks in tenth, marks in twelth, class obtained). Derive a class Bio-data from both these classes. Write a C++ program to prepare a bio-data of a student having Personnel and Academic information.

#include<iostream.h> #include<string.h> #include<conio.h>…

Consider a class Matrix Class Matrix { int a[3][3]; Public: //methods; }; Let m1 and m2 are two matrices. Find out m3=m1+m2 (use operator overloading).

#include<iostream.h> #include<conio.h> class Matrix {   int …

Write class declarations and member function definitions for a C++ base class to represent an Employee (emp-code, name). Derive two classes as Fulltime (daily rate, number of days, salary) and Parttime (number of working hours, hourly rate, salary). Write a menu driven program to: 1. Accept the details of ‘n’ employees and calculate the salary. 2. Display the details of ‘n’ employees. 3. Search a given Employee.

#include<iostream.h> #include<conio.h> #include<string.h>…

Consider a class Matrix Class Matrix { int a[3][3]; Public: //methods; }; Overload the – (Unary) should negate the numbers stored in the object.

#include<iostream.h> #include<conio.h> class Matrix { int a[…

In a bank, different customers having saving account. Some customers may have taken a loan from the bank. So bank always maintains information about bank depositors and borrowers. Design a Base class Customer (name, phone-number).Derive a class Depositor(accno, balance) from Customer. Again derive a class Borrower (loan-no, loan-amt) from Depositor. Write necessary member functions to read and display the details of ‘n’ customers.

#include<iostream.h> #include<conio.h> class Customer { prot…

Consider a class Matrix Class Matrix { int a[3][3]; Public: //methods; }; Let m1 and m2 are two matrices. Find out m3=m1*m2(use operator overloading).

#include<iostream.h> #include<conio.h> class Matrix {  int a…

Load More That is All