In my program I'm supposed to take a complex number to a power, however, my program only works when a complex number is taken to the second power and nothing beyond that. How can I fix my ExpC function?
#include <iostream>
#include "complex_1.hpp"
int main()
{
char choice;
complex a,b,c;
int n, m;
cout << endl;
cout << "Enter a complex number pair such as (5.1,2.3i): ";
a.InputC(cin);
cout << "Enter a complex number pair such as (5.1,2.3i): ";
b.InputC(cin);
cout << "Enter a choice: (a)dd, (s)ub,(m)ult,(d)ivide, or (e)xponent: ";
cin >> choice;
switch (choice)
{
case'a': c= a.AddC(b);
break;
case's': c= a.SubC(b);
break;
case'm': c= a.MultC(b);
break;
case'd': c= a.DivC(b);
break;
case'e' :
cout << "Which complex pair do you want to be taken to a power?\nEnter a choice 1 or 2:" << endl;
cin >> m;
cout << "Enter an integer for the compelx number to be taken a power to " << endl;
cin >> n;
if(m==1)
c=a.ExpC(a,n);
if(m==2)
c=b.ExpC(b,n);
else
cout << "Entry error";
break;
default : cout << "Entry error";
}
cout << endl;
cout << "Result is: ";
c.OutputC(cout);
cout << endl;
return 0;
}