cud

08-31-2012, 08:58 AM

Hey i am attempting to make a program that asks the user to enter 2 numbers and then determine all the numbers in between them that are perfect squares of numbers (ie 9 = 3squared, 8 = 2.....)

i am using a logical function to do so and i am currently getting an error on the line : C = SQRT(INTEGER(A))

this is my whole code

program Squared

implicit none

Integer :: A, B, Diff, N, I, C

Logical :: IS_SQUARE

5 write (*, *) "Please enter 2 integers, A and B, (B must be greater)"

read (*, *) A, B

Diff = (B-A)

do I = 1, Diff

if (A>B) then

write (*, *) "Sorry B must be the higher number please retry"

goto 5

else if (IS_SQUARE(A)) then

write (*, *) A

A = (A + 1)

end if

end do

end program Squared

LOGICAL FUNCTION IS_SQUARE(A)

Integer :: C, A

C = SQRT(INTEGER(A))

If (C**2 == A) Then

IS_SQUARE=.TRUE.

Else

IS_SQUARE=.FALSE.

End if

END LOGICAL FUNCTION IS_SQUARE(A)

i am using a logical function to do so and i am currently getting an error on the line : C = SQRT(INTEGER(A))

this is my whole code

program Squared

implicit none

Integer :: A, B, Diff, N, I, C

Logical :: IS_SQUARE

5 write (*, *) "Please enter 2 integers, A and B, (B must be greater)"

read (*, *) A, B

Diff = (B-A)

do I = 1, Diff

if (A>B) then

write (*, *) "Sorry B must be the higher number please retry"

goto 5

else if (IS_SQUARE(A)) then

write (*, *) A

A = (A + 1)

end if

end do

end program Squared

LOGICAL FUNCTION IS_SQUARE(A)

Integer :: C, A

C = SQRT(INTEGER(A))

If (C**2 == A) Then

IS_SQUARE=.TRUE.

Else

IS_SQUARE=.FALSE.

End if

END LOGICAL FUNCTION IS_SQUARE(A)