[Newbie]Fortran Program prints output after too many spaces?

Status
Not open for further replies.

xpress_embedo

Advanced Member level 4
Joined
Jul 5, 2011
Messages
1,154
Helped
161
Reputation
396
Reaction score
189
Trophy points
1,353
Location
India
Activity points
10,591
Hello!! I am new to fortran and try to use it and it works.
But the output displayed has too many spaces.

Here is the code:

Code Fortran - [expand]
1
2
3
4
5
6
7
8
9
10
Program Addition_of_Two_No
    IMPLICIT NONE
    INTEGER::num1,num2,answer
    Write(*,*)'Enter num1'
    read(*,*)num1
    Write(*,*)'Enter num2'
    read(*,*)num2
    answer=num1+num2
    write(*,*)'answer=',answer
    end Program Addition_of_Two_No





Why there is a gap when Enter number 1 and Enter Number 2.

Apart from that output is printed after a very big gap.
How to correct all these things.
 

Looks like you are learning FORTRAN by try and error method. How about reading a text book or reference manual? You'll want to review the chapter about formatted I/O. By now, you are using default output formating, resulting in the shown output formats. It's basically readable, but apparently specific format specifications are the next step.

I have been using FORTRAN the last time nearly 30 years ago, so I don't remember details related to your question.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…