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

Click For 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
 
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...

Similar threads

  • · Replies 25 ·
Replies
25
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 59 ·
2
Replies
59
Views
11K
  • · Replies 16 ·
Replies
16
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 5 ·
Replies
5
Views
9K
  • · Replies 5 ·
Replies
5
Views
5K
  • · Replies 9 ·
Replies
9
Views
2K