FoRtRaN
Friday, November 26, 2010
FoRtRaN: Intrinsic function of fortran
FoRtRaN: Intrinsic function of fortran: "Function Meaning Arg. Type Return Type ABS(x) absolute value of x ..."
Intrinsic function of fortran
Note that all trigonometric functions use radian rather than degree for measuring angles. For function ATAN(x), x must be in (-PI/2, PI/2). For ASIN(x) and ACOS(x), x must be in [-1,1].Function Meaning Arg. Type Return Type ABS(x) absolute value of x INTEGER INTEGER REAL REAL SQRT(x) square root of x REAL REAL SIN(x) sine of x radian REAL REAL COS(x) cosine of x radian REAL REAL TAN(x) tangent of x radian REAL REAL ASIN(x) arc sine of x REAL REAL ACOS(x) arc cosine of x REAL REAL ATAN(x) arc tangent of x REAL REAL EXP(x) exp(x) REAL REAL LOG(x) natural logarithm of x REAL REAL
- Conversion functions:
Function Meaning Arg. Type Return Type INT(x) integer part x REAL INTEGER NINT(x) nearest integer to x REAL INTEGER FLOOR(x) greatest integer less than or equal to x REAL INTEGER FRACTION(x) the fractional part of x REAL REAL REAL(x) convert x to REAL INTEGER REAL - Other functions:
Function Meaning Arg. Type Return Type MAX(x1, x2, ..., xn) maximum of x1, x2, ... xn INTEGER INTEGER REAL REAL MIN(x1, x2, ..., xn) minimum of x1, x2, ... xn INTEGER INTEGER REAL REAL MOD(x,y) remainder x - INT(x/y)*y INTEGER INTEGER REAL REAL
FoRtRaN: write a program to do numerical integration of any...
FoRtRaN: write a program to do numerical integration of any...: "implicit double precision (a-h,o-z) f(x)=x*x sum=0.0 write(*,*) 'x' read(*,*) x h=1/x do i=0,x sum=sum+f(i*h) enddo xsum=(..."
write a program to do numerical integration of any given function (by trapizoidal method)
implicit double precision (a-h,o-z) f(x)=x*x sum=0.0 write(*,*) 'x' read(*,*) x h=1/x do i=0,x sum=sum+f(i*h) enddo xsum=(sum+0.5*(f(0)+f(1)))*h write(*,*) xsum stop end
Thursday, November 25, 2010
write a program to find the factorial of a given number (using do command)
implicit double precision (a-h,o-z)
iprod=1
write(*,*) 'n'
read(*,*) n
do i=1,n
iprod=iprod*i
enddo
write(*,*) iprod
stop
end
iprod=1
write(*,*) 'n'
read(*,*) n
do i=1,n
iprod=iprod*i
enddo
write(*,*) iprod
stop
end
write a program to find the factorial of a given number (using goto command)
implicit double precision (a-h,o-z)
iprod=1
i=1
write(*,*) 'n'
read(*,*) n
10 if(i.LE.n) then
iprod=iprod*i
i=i+1
goto 10
else
write(*,*) iprod
goto 20
20 endif
stop
end
iprod=1
i=1
write(*,*) 'n'
read(*,*) n
10 if(i.LE.n) then
iprod=iprod*i
i=i+1
goto 10
else
write(*,*) iprod
goto 20
20 endif
stop
end
Subscribe to:
Posts (Atom)