15,616,746 members
1.00/5 (1 vote)
See more:
1. Define a C structure complx for a complex number with two data
members for the (real, imaginary) of the complex number. It should handle any real numbers! Use typedef to make your program readable.
2.write a procedure to raise any complex number to any integer power (π₯ + ππ¦)^n
Where π₯ and π¦ are real number and π is an integer!
3.write (π₯ + ππ¦)ππ  πe^ππ where π = β(π₯^2 + π¦^2) πππ tan^β1(π) = (π¦/π₯)
4. Then write (π₯ + ππ¦)^π ππ  π^π*π^πππ and go back to write the result as π^π*π^πππ ππ  (π^π*πππ (ππ) + ππ^π*π ππ(ππ))
5. In your procedure (function) you will use for-loop to compute the value
of π^π. Write programs to compute the π ππ(π₯) πππ πππ (π₯) functions. You may
use the math library header file and use the trig functions
[π ππ( ) , πππ ( ) πππ π‘ππ( )] and the square-root functions only!
6. Note that the π‘ππ(π₯) is multi-valued. check if it is in the fourth quadrant
7. The function should print the result on the screen in the form
Ans: ( x, jy)and return the function to main()

What I have tried:

#include<complex.h>
#include<mathlib.h>
typedef struct complex
{
float real,imag;
}
int main()
{
Posted
Updated 17-May-21 21:29pm

## Solution 1

tips:
- install Visual Studio to have an excellent IDE
- give explaining names to all code pieces and write some comments
- use functions and structs to seperate tasks and data
- make a lot of printf output
- use the debugger

## Solution 3

Well, your `struct` is a (little) start. You know, you can raise a complex number by iterative multiplication by itself[^].
I give you an example
C++
```#include <iostream>
using namespace std;

struct complex
{
double re;
double im;
};

ostream & operator << (ostream & os, const complex & c)
{
os << c.re << "+" << c.im << "j ";
return os;
}

complex complex_multiply( const complex & factor1, const complex & factor2)
{
complex result;
result.re = factor1.re * factor2.re - factor1.im * factor2.im;
result.im = factor1.re * factor2.im + factor1.im * factor2.re;
return result;
}

int main()
{
complex c{1,1};

cout << "c=" << c << ", c^2 = " << complex_multiply(c,c) << endl;
}```

Completing the exercises, now, is up to you.

v2