Posts

Showing posts from January, 2020

Implement a class Complex which represents the Complex Number data type. Implement the following operations: 1. Constructor (including a default constructor which creates the complex number 0+0i). 2. Overloaded operator+ to add two complex numbers. 3. Overloaded operator* to multiply two complex numbers. 4. Overloaded << and >> to print and read Complex Numbers.

Image
Implement a class Complex which represents the Complex Number data type. Implement the following operations: 1. Constructor (including a default constructor which creates the complex number 0+0i). 2. Overloaded operator+ to add two complex numbers. 3. Overloaded operator* to multiply two complex numbers. 4. Overloaded << and >> to print and read Complex Numbers. #include OUTPUT FOR THE PROGRAM using namespace std; class complex {    public:          float real,img;          complex()          {            real = 0;            img = 0;          }                     friend ostream & operator <<(ostream& ,complex& );         friend istream & operator >>(istream& ,complex& );         friend complex operator +(complex &c1,complex&a1);         friend complex operator -(complex &c2,complex&a2);         friend complex operator *(complex &c3,complex&a3);         friend complex operator /(comple

Write a menu driven program that will create a data file containing the list of telephone numbers in the following form John 23456 Ahmed 9876 ……….. ……… Use a class object to store each set of data, access the file created and implement the following tasks I. Determine the telephone number of specified person II. Determine the name if telephone number is known III. Update the telephone number, whenever there is a change.

Image
Write a menu driven program that will create a data file containing the list of telephone numbers in the following form John 23456 Ahmed 9876 …… Use a class object to store each set of data, access the file created and implement the following tasks. I. Determine the telephone number of specified person II. Determine the name if telephone number is known III. Update the telephone number, whenever there is a change. include #include #include OUTPUT FOR THE PROGRAM #include using namespace std; class person {    public:     char name[10];     int phno;         void input_data()     {       cout<<"\n Enter Name:-";       cin>>name;       cout<<"\n Enter Phone no:-";       cin>>phno;         }         void put_data()     {       cout<         }  }; int main() {     person rec;     int phone,pos,choice,offset,i;     fstream fp;     ifstream in;     ofstream out;     c