Académique Documents
Professionnel Documents
Culture Documents
PROGRAMAS EN FORTRAN 90 - I
1.- Este programa permite sumar los primeros 200 numeros de una sucesión de
números enteros.
Program suma_p_numeros
Integer::p,s,a
Print*,”****************”
Print*,”suma de p términos consecutivos” }
Print*,”de una sucesión de números reales”
Print*,”****************”
Print*,”cuantos términos de la sucesión desea sumar”
Read*,p
Print*,”índice de termino an, suma sn”
Read*,n,a,s
Do n=1 p,1
S=s+a
Print*”n,an,sn”
En do
Do
Nn+1
End do
End program suma_p_numeros
2.- Este programa sirve para formar los términos de una sucesión de números
reales.
En la línea 160 se indica los términos de se desean formar, también se podría
formarlos de 10 en 10. En la línea 170 se escribe la expresión del termino general
de la sucesión.
CODIGO DEL PROGRAMA EN FORTRAM 90
program problema_sucesion
real::an
integer::p,n
print*,"sucesion de numeros reales"
print*,"formacion de terminos de una sucesion"
print*,"*************************************"
print*,"cuantos terminos desea formar"
read*,p
print*,"indice", "termino"
print*,"******", "*******"
do n=1,p
an=(3.*n)/((n**2)+1)
print*,"n=",n,"a",n,an
end do
end program problema_sucesion
WIWI&DATA
5.- El presente programa sirve para calcular las anualidades de capitalización que
son unas cantidades fijas que se pagan al principio de cada año para formar junto
con sus intereses (compuesto) un capital al cabo de un cierto número de años.
El programa permite calcular las siguientes opciones:
La anualidad de capitalización A
El capital C formado al cabo de T años
El número de años T.
La expresión que nos da el capital final formado es la siguiente:
WIWI&DATA
De esta expresión se deducen las demás para efectuar los cálculos de las otras
opciones.
CÓDIGO DEL PROGRAMA EN FORTRAN 90
program capitalizacion
integer::opcion,T
real::C,R,A,X
character(len=1)::otro="s"
do while(otro=="s" .or. otro=="S")
print*,"**********************************************************"
print*
print*,"ANUALIDADES DE CAPITALIZACION"
print*
print*,"**********************************************************"
print*
print*,"Este programa le permite calcular:"
print*
print*,"1. La anualidad de capitalizacion"
print*,"2. El capital formado en T annos"
print*,"3. El numero de annos"
print*
print*,"Segun la opcion deseada pulse el numero que le precede"
read*,opcion
if(opcion==1) then
print*,"CALCULO DE LA ANUALIDAD DE CAPITALIZACION"
print*
print*,"CAPITAL QUE SE DESEA FORMAR C="
READ*,C
PRINT*,"TANTO POR CIENTO ANUAL R="
READ*,R
PRINT*,"NUMERO DE ANNOS T="
READ*,T
A=(C*R/100.)/((1+R/100.)*(1+R/100.)**(T-1))
PRINT*,"LA ANUALIDAD NECESARIA PARA FORMAR EL CAPITAL ",C,"
ES=", A
ELSE
IF(OPCION==2) THEN
PRINT*,"CALCULO DEL CAPITAL FORMADO AL CABO DE T
ANNOS"
PRINT*,"ANUALIDAD DE CAPITALIZACION A="
READ*,A
PRINT*,"TANTO POR CIENTO ANUAL R="
READ*,R
PRINT*,"NUMERO DE ANNOS T="
READ*,T
WIWI&DATA
C=A*(1+R/100.)*((1+R/100.)**(T-1))*100/R
PRINT*,"EL CAPITAL FORMADO AL CABO DE ",T," ANNOS ES=",C
ELSE
IF(OPCION==3)THEN
PRINT*,"CALCULO DE NUMERO DE ANNOS"
PRINT*,"ANUALIDAD A PAGAR A="
READ*,A
PRINT*,"CAPITAL FORMADO AL CABO DE T ANNOS C="
READ*,C
PRINT*,"TANTO POR CIENTO ANUAL R="
READ*,R
X=(C*R/100.)/(A*(1+R/100.))
T=LOG10(1+X)/LOG10(1+R/100.)
PRINT*,"EL NUMERO DE ANNOS ES=", T
END IF
END IF
END IF
PRINT*,"REALIZAR OTRO CALCULO S/N"
READ*,otro
END DO
end program capitalizacion
READ*, R
DO
A=A1*R**(N-1)
END DO
PRINT*,"EL TERMINO N-ESIMO ="
PRINT*,"CALCULO DE LA RAZON"
PRINT*,"TERMINO PRIMER A1 ="
READ*, A1
PRINT*, "TERMINO N-ESIMO AN = "
READ*, AN
PRINT*, " NUEKMRO DE TERMINOS N = "
READ*, N
DO
R=(AN/AN)**(1/(N-19))
PRINT*,"LA RAZON O DIFERENCIA DE LA PROGRESION ES R = ", R
END DO
PRINT*,"CALCULO DEL TERMINO PRIMERO"
PRINT*,"RAZON = "
READ*, R
PRINT*, "TERMINO N-ESIMO AN = "
READ*, AN
PRINT*, " NUMERO DE TERMINOS = "
READ*, N
DO
A1=AN/(R**(N-1))
PRINT*,"PRIMER TERMINO DE PROGRESION A1 =", A1
END DO
PRINT*,"CALCULO DEL NUMERO DE TERMINOS"
PRINT*,"RAZON = "
READ*, R
PRINT*, "TERMINO N-ESIMO AN = "
READ*, AN
PRINT*, " TERMINO PRIMERO A1 = "
READ*, A1
DO
N=1+(LOG(AN)-LOG(A1))/LOG(R)
PRINT*,"EL NUMERO DE TERMINOS N = ", N
END DO
PRINT*,"INTERPOLAR H MEDIOS GEOMETRICOS ENTRE DOS TERMINOS
DADOS"
PRINT*,"CUANTOS TERMINOS DESEA INTERPOLAR H = "
READ*, H
PRINT*, "INTRODUSCA EL PRIMERO Y EL ULTIMO TERMINO ENTRE LOS
QUE QUIERE INTERPOLAR";H; "MEDIOS GEOMETRICOS"
READ*, P,U
DO
R=(U/P)**(1/(H+1))
WIWI&DATA
IF (opcion==3) then
print*,"CALCULO DEL TERMINO N ÈSIMO"
print*,"Ingrese el primer termino"
read*,a1
print*,"ingrese el numero de terminos"
read*,n
print*,"ingrese la razon"
read*,d
an=a1+(n-1)*d
print*,"El termino N esimo es:",an
else
IF (opcion==4) then
print*,"CALCULO DEL PRIMER TERMINO"
print*,"Ingrese el numero de terminos"
read*,n
print*,"Ingrese la razon"
read*,d
print*,"Ingrese el termino N esimo"
read*,an
a1=an-(n-1)*d
print*,"El primer termino es:",a1
else
IF (opcion==5) then
print*,"INTERPOLAR H MEDIOS ARITMETICOS ENTRE DOS TERMINOS
DADOS"
print*,"Cuantos medios desea interpolar"
read*,H
print*,"Introduzca el primero y el ultimo termino entre los que quiere interpolar"
read*,p,u
d=(u-p)/(h+1)
print*
print*,"La razon de la progresion es:",d
print*,"Los medios aritmeticos interpolados son:"
do i=1,h
t=p+i*d
print*,T
end do
end if
end if
end if
end if
end if
print*,"realizar otro calculo S/N"
read*,otro
end do
end program