Help with complex # to polar form

I'm tasked with creating a program that allows the user to enter two sets of imaginary and real numbers, which then provides the answer in rectangular and polar form. I have it set up to where the answer comes out in rectangular (a+bi) but am unable to figure out why the answer doesn't display polar as well. I also noticed the "sqrt" and "atan" (located just several lines down) are underlined in red, so I'm guessing it's an issue with one of the headers (or lack of).

#include<iostream>
#include<conio.h>
#include<string.h>
#include<stdio.h>
#include<math.h>
#include<cmath>
#include<cstdio>
#include<ctime>
#include<fstream>
#include<iomanip>
using namespace std;
class complex
{
int i,r;
public:
void read()
{
std::cout<<"\nEnter Real Part:";
std::cin>>r;
std::cout<<"Enter Imaginary Part:";
std::cin>>i;
}
void display()
{
std::cout<<"\n= "<<r<<"+"<<i<<"i";
}
void display1()
{
std::cout<<"\n= "<<sqrt((i*i)+(r*r))<<"angle of"<<atan(r/i);
}
complex operator+(complex a2)
{
complex a;
a.r=r+a2.r;
a.i=i+a2.i;
return a;
}
complex operator-(complex a2)
{
complex a;
a.r=r-a2.r;
a.i=i-a2.i;
return a;
}
complex operator*(complex a2)
{
complex a;
a.r=(r*a2.r)-(i*a2.i);
a.i=(r*a2.i)+(i*a2.r);
return a;
}
complex operator/(complex a2)
{
complex a;
a.r=((r*a2.r)+(i*a2.i))/((a2.r*a2.r)+(a2.i*a2.i));
a.i=((i*a2.r)-(r*a2.i))/((a2.r*a2.r)+(a2.i*a2.i));
return a;
}
};
void main()
{
int ch;
std::cin;
complex a,b,c;
do
{
std::cout<<"\n1.Addition 2.Substraction";
std::cout<<" 3.Mulitplication 4.Division 5.Exit\n";
std::cout<<"\nEnter the choice :";
std::cin>>ch;
switch(ch)
{
case 1:
std::cout<<"\nEnter The First Complex Number:";
a.read();
a.display();
std::cout<<"\nEnter The Second Complex Number:";
b.read();
b.display();
c=a+b;
c.display();
break;
case 2:
std::cout<<"\nEnter The First Complex Number:";
a.read();
a.display();
std::cout<<"\nEnter The Second Complex Number:";
b.read();
b.display();
c=b-a;
c.display();
break;
case 3:
std::cout<<"\nEnter The First Complex Number:";
a.read();
a.display();
std::cout<<"\nEnter The Second Complex Number:";
b.read();
b.display();
c=a*b;
c.display();
break;
case 4:
std::cout<<"\nEnter The First Complex Number:";
a.read();
a.display();
std::cout<<"\nEnter The Second Complex Number:";
b.read();
b.display();
c=a/b;
c.display();
break;
}
}while(ch!=5);
getch();
}
It compiles fine, but you never call display1()
Topic archived. No new replies allowed.