Created
March 9, 2011 12:56
-
-
Save tormaroe/862135 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PROGRAM CALCULATE | |
! | |
! Program to calculate the sum of up to n values of x**3 | |
! where negative values are ignored. | |
! | |
IMPLICIT NONE | |
INTEGER I,N | |
REAL SUM,X,Y | |
READ(*,*) N | |
SUM=0 | |
DO I=1,N | |
READ(*,*) X | |
IF (X.GE.0.0) THEN | |
Y=X**3 | |
SUM=SUM+Y | |
END IF | |
END DO | |
WRITE(*,*) 'This is the sum of the positive cubes:',SUM | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment