C C++/Matlab/Fortran 77Dictionary 335
write (6,*)"0toquit"
write (6,*) " ------------------------------"
read (5,*) n
If(n.eq.0) Go to 99
write (6,101)
c--
q = 0.0D0
Do i=0,n-1
p = 2**i
q = q+p
write (6,100) i+1,p,q
End Do
Go to 98! return to repeat
c--
99 Continue! done
100 Format (1x,i5,2(1x,i15))
101 Format (" bits",5x,"increment",5x,"largest integer")
Stop
End
At the beginning of Section 4.6, we discussed the codeprj.ccthat com-
putes the inner product (projection) of two vectors. The equivalentFortran
77 program contained in the fileprj.f is:
Program prj
Double precision a(2), b(2), prod
a(1) = 0.1
a(2) = 0.2
b(1) = 2.1
b(2) = 3.1
call prj (a, b, n, prod)
write (6,*) " inner product: ", prod
Stop
End
c-------
subroutine prj (a, b, n, prod)
Double precision a(2), b(2), prj