ALGORITHM:
Step 1: Start the program.
Step 2: Declare the class.
Step 3: Declare the variables and its member function.
Step 4: Using the function getvalue() to get the two numbers.
Step 5: Define the function operator ++ to increment the values
Step 6: Define the function operator – -to decrement the values.
Step 7: Define the display function.
Step 8: Declare the class object.
Step 9: Call the function getvalue
Step 10: Call the function operator ++() by incrementing the class object and call the function display.
Step 11: Call the function operator – -() by decrementing the class object and call the function display.
Step 12: Stop the program.
PROGRAM:
| cout<<"Enter the Two Numbers:"; |
| |
| cout<<a<<"+\t"<<b<<"i"<<endl; |
| |
| cout<<"Increment Complex Number\n"; |
| |
| cout<<"Decrement Complex Number\n"; |
| |
|
Output:
Enter the two numbers: 3 6
Increment Complex Number
4 + 7i
Decrement Complex Number
3 + 6i
0 Response for the "To write a program to find the complex numbers using unary operator overloading."
Post a Comment