the calculator with fortran 77

Upload: sayan-kundu

Post on 26-Feb-2018

220 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/25/2019 The Calculator With Fortran 77

    1/3

    C The Calculator

    Real a,b,add,prod,subt,div,fact,pow,n,C

    100 Write(*,*)'What do you want me to do'

    Write(*,*)'1. Addition 2. Subtraction 3. Multiplication'

    Write(*,*)'4. Division 5. Factorial 6. Power'

    Read(*,*) n

    If(n.eq.1) then

    Write(*,*)'Provide two numbers to add'

    Read(*,*) a, b

    C=a+b

    Write(*,*)'The answer is', C

    Write(*,*)'Do you want me to do some more operation 7. Yes 8. No'

    Read(*,*) m

    If(m.eq.7) then

    Goto 100

    Else

    Goto 99

    Endif

    Endif

    If(n.eq.2) then

    Write(*,*)'Provide two numbers to subtract'

    Read(*,*) a, b

    C=a-b

    Write(*,*)'The answer is', C

    Write(*,*)'Do you want me to do some more operation 7. Yes 8. No'

    Read(*,*) m

    If(m.eq.7) then

    Goto 100

    Else

    Goto 99

    Endif

  • 7/25/2019 The Calculator With Fortran 77

    2/3

    Endif

    If(n.eq.3) then

    Write(*,*)'Provide two numbers to multiply'

    Read(*,*) a, b

    C=a*b

    Write(*,*)'The answer is', C

    Write(*,*)'Do you want me to do some more operation 7. Yes 8. No'

    Read(*,*) m

    If(m.eq.7) then

    Goto 100

    Else

    Goto 99

    Endif

    Endif

    If(n.eq.4) then

    Write(*,*)'Provide two numbers to divide'

    Read(*,*) a, b

    C=a/b

    Write(*,*)'The answer is', C

    Write(*,*)'Do you want me to do some more operation 7. Yes 8. No'

    Read(*,*) m

    If(m.eq.7) then

    Goto 100

    Else

    Goto 99

    Endif

    Endif

    If(n.eq.5) then

    Write(*,*)'Provide the number whose factorial is to take'

    Read(*,*) a

    mul=1

  • 7/25/2019 The Calculator With Fortran 77

    3/3

    do i=1,a

    mul=mul*i

    enddo

    Write(*,*)'The answer is', mul

    Write(*,*)'Do you want me to do some more operation 7. Yes 8. No'

    Read(*,*) m

    If(m.eq.7) then

    Goto 100

    Else

    Goto 99

    Endif

    Endif

    If(n.eq.6) then

    Write(*,*)'Provide the number whose power is to take'

    Read(*,*) a

    Write(*,*) a, 'Raise to which power'

    Read(*,*) b

    c=a**b

    Write(*,*)'The answer is', C

    Write(*,*)'Do you want me to do some more operation 7. Yes 8. No'

    Read(*,*) m

    If(m.eq.7) then

    Goto 100

    Else

    Goto 99

    Endif

    Endif

    99 Stop

    End