Skip to content

Instantly share code, notes, and snippets.

View natebenes's full-sized avatar

Nate Benes natebenes

View GitHub Profile
<?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
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
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
INTEGER FUNCTION q2bonus(n)
IMPLICIT NONE
INTEGER, INTENT(IN) :: n
q2bonus = n*(n+1)
END FUNCTION
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)
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)
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
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.
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.