Fortran Inputting a Complex Number in Fortran 90 for DeMoivre's Theorem

AI Thread Summary
To input a complex number in Fortran 90, the user should declare the variable as complex (e.g., complex a) and input the real and imaginary parts together in parentheses, such as "(1.43, 22.3)". Using the read statement like read(*,*) a will lead to runtime errors if the input is not formatted correctly. The discussion also references a StackOverflow link that provides guidance on reading complex numbers from a file, emphasizing that the real and imaginary parts must follow one another in the input. The combination of these parts into a single complex number can then be processed using DeMoivre's Theorem in the program.
waver.
Messages
8
Reaction score
0
i have a a little problem in fortan90 i just wanted to know how to input a complex number ( input real and img part alone ) all i want to do is to make a simple program about DeMoivres Theorem i have been around in google
all i know how to declare a argument as complex
complex a
then how to let the user input the real and img part for argument a
i did read(*,*)a
every time it give runtime error :)
thanks in advance
 
Technology news on Phys.org
A google search with fortran90 and complex returned quite a few links.

In any case, if you want to read a complex number straight into variable 'a', for example, as you show above, you need to enter your value as a complex number, i.e., enclosed in parenthesis, in other words, you type, say, "(1.43, 22.3)"
 
thanks guys for helping specially gsal i used your idea and its works thank a lot
n7vc8.jpg
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.

Similar threads

Replies
25
Views
3K
Replies
4
Views
2K
Replies
2
Views
1K
Replies
59
Views
11K
Replies
16
Views
2K
Replies
5
Views
2K
Replies
5
Views
9K
Replies
5
Views
5K
Replies
9
Views
2K
Back
Top