14

Do_ While- 4TA CLASE FORTRAN

Embed Size (px)

DESCRIPTION

FORTRAN

Citation preview

Page 1: Do_ While- 4TA CLASE FORTRAN
Page 2: Do_ While- 4TA CLASE FORTRAN
Page 3: Do_ While- 4TA CLASE FORTRAN
Page 4: Do_ While- 4TA CLASE FORTRAN
Page 5: Do_ While- 4TA CLASE FORTRAN
Page 6: Do_ While- 4TA CLASE FORTRAN
Page 7: Do_ While- 4TA CLASE FORTRAN
Page 8: Do_ While- 4TA CLASE FORTRAN
Page 9: Do_ While- 4TA CLASE FORTRAN
Page 10: Do_ While- 4TA CLASE FORTRAN
Page 11: Do_ While- 4TA CLASE FORTRAN

!uso de ciclos repetitivos condicionales!el usuario no sabe cuantas veces se va a repetir!el proceso del calculo y solo depende de la condicion!logica ademas la variable inicializada dentro del!bucle de repeticion debe ser una variable contador!Do while

!program uso_while!integer::w!real::z!w=0 !variable inicializada!Do while (w<=10)!if (W==2) then!w=w+1!z=(w**2+w+3.)/(w-2.)!print*,w,z!w=w+1!end if!z= (w**2+w+3.)/(w-2.) !print*,w,z!w=w+1 ! w es una variable de tipo contador!end do!end program uso_while

!**************CICLOS ANIDADOS!PROGRAM ANIDADOS!INTEGER::I,J!PRINT*,"OBSERVE LA SALIDA DE I y J "!PRINT*!PRINT*," I J "!PRINT*," --- ---"!DO I=1,5! DO J=1,3! PRINT*,I,J

Page 12: Do_ While- 4TA CLASE FORTRAN

! END DO!END DO!END PROGRAM ANIDADOS

!**************CICLOS ANIDADOS CON DO CONDICIONAL!PROGRAM ANIDADOS_DOWHILE!INTEGER::I,J!PRINT*,"OBSERVE LA SALIDA DE I y J "!PRINT*!PRINT*," I J "!PRINT*," --- ---"!I=1 !Variables inicializadas!J=1 !Variables inicializadas!Do while (I<=5)! J=1! Do while (J<=3)! PRINT*,I,J! j=j+1! END DO!i=i+1!END DO!END PROGRAM ANIDADOS_DOWHILE

!Elaborar un programa en f90 que evalue la funcion!f(x,y)= (x^2-2xy+3)/(x^2+y^3 ), donde x varia de ![-3 a 5] y la variable y varia de [2 a 8]!grafique esta funcion

!program eval_funcion!real::x,y!real::fxy !integer::i,j!x=-3!y=2!PRINT*," x y F(X,Y) "!PRINT*," === === ====="!DO i=1,9! DO j=1,7

Page 13: Do_ While- 4TA CLASE FORTRAN

! fxy=(x**3-2*x*y+3.)/(x**2+y**3 )! !fxy=(x**2+y**2)*(sin(8*atan(y,x)))! print*,x,y,fxy! x=x+1! y=y+1! end do! end do! end program eval_funcion

!problema, evaluar la funcion y=seno(x)*exp(-x)!donde x varia desde -6pi a +6pi con incrementos!de pi/20, grafique la funcion en excel

PROGRAM SENOIDALREAL::X,YREAL,PARAMETER::PI=3.1416X=-6*PIDO WHILE(X<=6*PI)Y=SIN(X)*EXP(-X)PRINT*,X,YX=X+PI/20END DOEND PROGRAM SENOIDAL