

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Sample Source Code :- /* Implement a class Complex which represents the Complex Number data type. Implement the following operations:
temp.real = real + obj.real; temp.img = img + obj.img; return (temp); } //Overloaded operator * complex complex::operator * ( complex obj ) { complex temp; temp.real = real * obj.real - img * obj.img; temp.img = real * obj.img + img * obj.real; return (temp); } //Main Function int main() { complex a, b, c, d; cout << "1st Complex Number - Enter Real and Imaginary\n"; cin >> a; cout << "2nd Complex Number - Enter Real and Imaginary\n"; cin >> b; cout << "\nArithmetic Operation :"; c = a + b; cout << "\nAddition ="<<c; d = a * b; cout << "\nMultipication = "<<d; return 0; } <----------------------------------------------------------------------> Sample Output :- 1st Complex Number - Enter Real and Imaginary 5 9 2nd Complex Number - Enter Real and Imaginary 7 3 Arithmetic Operation : Addition =12+15i Multipication = 8+78i <---------------------------------------------------------------------->