0% found this document useful (0 votes)
10 views2 pages

Rohini Pract 1.cpp

Se Artificial intelligence and data science

Uploaded by

tejasrahane27
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views2 pages

Rohini Pract 1.cpp

Se Artificial intelligence and data science

Uploaded by

tejasrahane27
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

#include<iostream>

using namespace std;


class complex
{
int real, imag;
public:
complex()
{
real=0;
imag=0;
}
void read()
{
cout<<"\n enter real and imag part";
cin>>real>>imag;
}
void display()
{
cout<<real<<"+"<<imag<<"i";
}
complex operator +(complex c2)
{
complex c3;
[Link]=real+[Link];
[Link]=imag+[Link];
return c3;
}
complex operator *(complex c2)
{
complex c4;
[Link]=(real*[Link])+(imag*[Link]);
[Link]=(real*[Link])+(imag*[Link]);
return c4;
}
};
int main()

{
complex c1,c2,c3,c4;
int ch;
char choice;
do
{
cout<<"\n 1. read complex numbers\n 2. Add two complex numbers \n [Link]
two complex number";
cout<<"\n enter your choice ";
cin>>ch;
switch(ch)
{
case 1: [Link]();
[Link]();
break;
case 2:
c3=c1+c2;
[Link]();
[Link]();
cout<<"\n Addition";
[Link]();
break;
case 3:c4=c1*c2;
[Link]();
[Link]();
cout<<"\n Multiplication";
[Link]();
default:cout<<"\n Invalid choice";

}
cout<<"\n Do you want to continue(y/n)";
cin>>choice;
}while(choice=='y');
return 0;
}

You might also like