Already have an account? Get multiple benefits of using own account!
Login in your account..!
Remember me
Don't have an account? Create your account in less than a minutes,
Forgot password? how can I recover my password now!
Enter right registered email to receive password!
Aim: To implement a program to add two complex numbers using constructors.
Code:
class complex
{
int real;
int img;
public:
complex(int r=0, int i=0);
complex(complex c1, complex c2);
void display();
};
complex :: complex(int r,int i)
real=r;
img=i;
}
complex :: complex(complex c1,complex c2)
real=c1.real+c2.real;
img=c1.img+c2.img;
void complex :: display()
cout< } void main() { int r1,r2,i1,i2; clrscr(); cout<<"\nEnter first complex no:\nReal:"; cin>>r1; cout<<"Imaginary:"; cin>>i1; cout<<"\nEnter second complex no:\nReal:"; cin>>r2; cout<<"Imaginary:"; cin>>i2; complex c1(r1,i1); cout<<"\nFirst:\t\t"; c1.display(); cout<<"\nSecond:\t\t"; complex c2(r2,i2); c2.display(); complex c3(c1,c2); cout<<"\n----------------------\nAddition:\t"; c3.display(); getch(); } Output: Enter first complex no: Real:25 Imaginary:3 Enter second complex no: Real:12 Imaginary:71 First: 25+3i Second: 12+71i ---------------------- Addition: 37+74i
void main()
int r1,r2,i1,i2;
clrscr();
cout<<"\nEnter first complex no:\nReal:";
cin>>r1;
cout<<"Imaginary:";
cin>>i1;
cout<<"\nEnter second complex no:\nReal:";
cin>>r2;
cin>>i2;
complex c1(r1,i1);
cout<<"\nFirst:\t\t";
c1.display();
cout<<"\nSecond:\t\t";
complex c2(r2,i2);
c2.display();
complex c3(c1,c2);
cout<<"\n----------------------\nAddition:\t";
c3.display();
getch();
Output:
Enter first complex no:
Real:25
Imaginary:3
Enter second complex no:
Real:12
Imaginary:71
First: 25+3i
Second: 12+71i
----------------------
Addition: 37+74i
SquareMaze The SquareMaze class should be declared and defined in maze.h and maze.cpp, respectively. Each SquareMaze object will represent a randomly-generated square maze and its
write a function named "fact"that takes one integer arguments,call them "num" and returns as ..............
A: The procedure of encoding the parameter types along with the function/method name into a unique name is called as name mangling. The inverse procedure is called demangling. F
Write a function that calculates the number of elapsed days between two dates. For example the days between Feb 3, 1970 and June 21, 1980? Becareful for the Leap year
Explain the working of strcmp and strcat Function? strcmp() : This function is meant to use to compare two strings. The strcmp() function acknowledge two strings as argument
Spider webs have two types of silk, sticky silk and strength silk, spiders do not move on the sticky silken threads only on the strength threads. Assume one type of spider creates
Normal 0 false false false EN-IN X-NONE X-NONE MicrosoftInternetExplorer4
Program1: Write a program to find the factorial of a given number. The input is user given. Final output is printed out on to the screen. Program2: Write a program to gene
The following is the formula that can be used to complete that calculation: Monthly Payment = Monthly Interest Rate / (1 - (1 + Monthly Interest Rate) -Payment Interval )) *
Ask queByteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particular colo
Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!
whatsapp: +91-977-207-8620
Phone: +91-977-207-8620
Email: [email protected]
All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd