CLSCMPLX - } void complex :: divide(complex c1,complex c2)...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
#include<iostream.h> #include<conio.h> # class complex { int x; int y; public: void getval(); void putval(); void add(complex,complex); void sub(complex,complex); void multiply(complex,complex); void divide(complex,complex); }; } void complex::getval() { cout<<"Enter the value of x & y"; cin>>x>>y; } void complex :: putval() { cout<<x<<"+i"<<y<<endl; } void complex :: add(complex c1,complex c2) { x=c1.x+c2.x; y=c1.y+c2.y; } void complex :: sub(complex c1,complex c2) { x=c1.x-c2.x; y=c1.y-c2.y; } void complex :: multiply(complex c1,complex c2) { x=(c1.x*c2.x)-(c1.y*c2.y); y=(c1.x*c2.y)+(c1.y*c2.x);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: } void complex :: divide(complex c1,complex c2) { float a,b; a=float((c1.x*c2.x)+(c1.y*c2.y))/((c2.x*c2.x)+(c2.y*c2.y)); b=float((c1.y*c2.x)-(c1.x*c2.y))/((c2.x*c2.x)+(c2.y*c2.y)); cout<<"d "<<a<<"+i("<<b<<")"<<endl; } void main() { clrscr(); complex a1,a2,a3,a4,a5,a6; a1.getval(); a2.getval(); a3.add(a1,a2); a4.sub(a1,a2); a5.multiply(a1,a2); a6.divide(a1,a2); cout<<"Addition is "; a3.putval(); cout<<"Subtraction is "; a4.putval(); cout<<"Multiplication is "; a5.putval(); getch(); }...
View Full Document

This note was uploaded on 10/25/2010 for the course CMPN SEM1 taught by Professor Thakur during the Fall '06 term at University of Mumbai.

Page1 / 2

CLSCMPLX - } void complex :: divide(complex c1,complex c2)...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online