Support Forums

Full Version: some help in program in fortran please!!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hello every one ....
they asked us to write a program in FORTRAN language , collects two large numbers reach their height to 50 words means like:
111111111111111111111111111111 1111111111 ..... 11111111111
Please note that I for the first time I write a program in a language FORTRAN (very simple programs .. tyro)
Well thought program that enter long numbers in the form of a script(string) in the sense .. Character (LEN=50):: a
then the user puts the number in a : a = 11111111111111 ....
Then squint(transfer) this figure by a table code ASCII to numbers
So I do with the other number, then gather(collecte) them by Boucle'' DO''
Here are the attempt in the program ......... in this attempt i use LEN = 2 but this program did not work as it should because i have no experience At fortron ..I did not understand very well the problem


PROGRAM TP
character(LEN=2)::Nombre1
character(LEN=2)::Nombre2
character(LEN=3)::Nombre3
integer n1, n2, res1, res2

C
read(*,*) nombre1
read(*,*) nombre2
res2 = 0

do i = 2, 1, -1
n1 = ichar(Nombre1(i:i)) -48
n2 = ichar(Nombre2(i:i))-48

res1 = n1 + n2 + res2
res2 = res1/10

res1 = mod(res1,10)
nombre3(i:i) = char(res1 + 48)
enddo

nombre3(1:1) = char(res2 + 48)
print*, "voila"
write(*,*) nombre3


END PROGRAM TP