Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
FORTRAN programming IF statement?
I'm writing a program to tell in a number input is a leap year or not, the statement has to be if x is divisible by 100 and divisible by 400 then its not a leap year the statement i've got is
IF x/100=INTEGER AND x/400=INTEGER THEN
if it satisfies these requirements then it will print 'this is not a leap year'
I'm new to if statements so i don't know if i can use AND and I'm not sure if =INTEGER will work either
2 Answers
- Vincent GLv 71 decade agoFavorite Answer
There is not "is this an integer"test in Fortran
What you need to do, ideally, is to use the modulo function, which returns the reminder from division.
For instance, MOD(x,100) will return 0 if x is 100, 200, 300 and so on, but will return 1 if x is 101, 2 if x is 102, and so on.
Check the result of the modulo function against zero and you should be all set.
By the way, the rule is that it is a leap year if it is divisible by 4 (i.e. MOD(year,4) is zero); except if it is a century (i.e. MOD(year,100). However, if it is divisible by 400 (MOD(year,400) is zero) then it IS a leap year.
- ?Lv 44 years ago
in the journey that your 'PRINT' assertion is meant to furnish you a run down on the certainly flipping of the LOGICAL 'VOK' then maybe this is merely a remember of having it badly located. As you have it now, VOK is obtainable and then assigned by using the attempt; so it maintains to be fake until at last the 2d this is replaced, which could be outputted on condition which you went trough extra iterations interior the DO loop. Which this isn't any longer, in case you're checking for '3.7'.