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
Explain Operators in C Language? The C language is very rich in built - in - operators and it places more significance on operators than do most other computer languages. The C
Project Description: I will need a tutor that would help me out in Data Structure and learning Algorithm more at the mathematical/algorithmic level. The book is written by "by T
P o i n t e r d e c l a r a t i o n f o r C l a s s : M m; M * p m; / / C la ss M i s d e c l a r e d a s
Selection sort - C program: Write a program to define a selection sort. void main() { clrscr(); int a[100],ch,n; cout cin>>n; for (int i=0;i
#include #include #include void* memorycopy (void *des, const void *src, size_t count) { size_t n = (count + 7) / 8; char* destination = (char *) des; char* source =
FIT 3042 System Tools and Programming Languages Semester 1 2013 Assignment 1 An SDL video player for a custom video format Worth: 20% of final mark. Must be completed individually
A palindrome is a string that reads the same from both the ends. Given a string S convert it to a palindrome by doing character replacement. Your task is to convert S to palindrome
In this problem, you will write a program that implements two algorithms for performing exact inference given a Bayesian network, namely, enumeration and variable elimination. Your
What are the different types of endless loops? An endless loop can be of two types: i.) A loop that is intentionally designed to go round and round until the condition withi
Given a string, print all possible palindromic partitions using recursion
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: +1-415-670-9521
Phone: +1-415-670-9521
Email: [email protected]
All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd