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
<?php | |
// A very simple function for posting gists using cURL | |
function postGist($gistname,$gistextension,$gistcontents) | |
{ | |
// clean POST variables | |
$gistname = urlencode($gistname); | |
$gistextension = urlencode($gistextension); | |
$gistcontents = urlencode($gistcontents); | |
// Define the API endpoint |
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 q1 | |
INTEGER :: A,B,C | |
REAL :: X,Y,Z | |
A = 10 | |
B = 20 | |
C = 30 | |
X = 5.0 | |
Y = 10.0 | |
Z = 20.0 |
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 Q2 | |
integer I, N, Sum | |
data I, N, Sum, Result / 0, 0, 0, 0 / | |
print *, 'Enter a positive integer' | |
read *, N | |
print *, ' i Sum' | |
print *, '----------------' | |
do 100 , I = 1, N, 1 | |
Sum = Sum + I + ( N - I + 1) | |
print *, I, Sum |
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
INTEGER FUNCTION q2bonus(n) | |
IMPLICIT NONE | |
INTEGER, INTENT(IN) :: n | |
q2bonus = n*(n+1) | |
END FUNCTION |
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 Q3 | |
integer I, J, K, Switch | |
! NB removed stray (,) after K in DATA statement | |
data I, J, K / 1, 2, 3/ | |
K = Switch (I, J, K) + Switch (J, K, I) + Switch (K, I, J) | |
print *, I, J, K | |
stop | |
end | |
integer function Switch(X, Y, Z) |
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 Q3 | |
integer I, J, K, Switch | |
! NB removed stray (,) after K in DATA statement | |
data I, J, K / 1, 2, 3/ | |
K = Switch (I, J, K) + Switch (J, K, I) + Switch (K, I, J) | |
print *, I, J, K | |
stop | |
end | |
integer function Switch(X, Y, Z) |
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
INTEGER FUNCTION caseDifference(string) | |
IMPLICIT NONE | |
CHARACTER (LEN=*), INTENT(IN) :: string | |
INTEGER :: stringLength = LEN_TRIM(string) | |
INTEGER :: i, caseDifference | |
INTEGER :: uppercase = 0, lowercase = 0 | |
DO i = 1, stringLength, 1 | |
IF (LLE("a",string(i:i)) .AND. LGE(string(i:i), "z")) THEN |
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 ComputeFactorial | |
! @author: Nate Benes | |
USE FactorialModule | |
IMPLICIT NONE | |
INTEGER, DIMENSION(2,10) :: arrayOfNumbers | |
INTEGER :: userInput, factorial | |
INTEGER :: total = 0,i,m,n | |
! One of many ways to fill the array. | |
! reading from a file is also OK |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
LOGICAL FUNCTION aprilFools(day, month) | |
INTEGER :: day, month | |
IF ((day > 31) .OR. (day < 1)) THEN | |
! Invalid input | |
day = 1 | |
END IF | |
IF ((day == 1) .AND. (month == 4)) THEN | |
aprilFools = .true. |