Last active
July 25, 2020 13:24
-
-
Save Foadsf/f887f03a4cbf04921e98d7ccfc0e74b1 to your computer and use it in GitHub Desktop.
mixed FORTRAN-C programing for this question: https://stackoverflow.com/questions/53585628/minimum-modification-to-make-a-visual-studio-fortran-c-mixed-code-gfortran-gcc-c
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
/* File CMAIN.C */ | |
#include <stdio.h> | |
extern int __stdcall FACT (int n); | |
extern void __stdcall PYTHAGORAS (float a, float b, float *c); | |
main() | |
{ | |
float c; | |
printf("Factorial of 7 is: %d\n", FACT(7)); | |
PYTHAGORAS (30, 40, &c); | |
printf("Hypotenuse if sides 30, 40 is: %f\n", c); | |
} | |
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
C File FORSUBS.FOR | |
C | |
INTEGER*4 FUNCTION Fact (n) | |
INTEGER*4 n [VALUE] | |
INTEGER*4 i, amt | |
amt = 1 | |
DO i = 1, n | |
amt = amt * i | |
END DO | |
Fact = amt | |
END | |
SUBROUTINE Pythagoras (a, b, c) | |
REAL*4 a [VALUE] | |
REAL*4 b [VALUE] | |
REAL*4 c [REFERENCE] | |
c = SQRT (a * a + b * b) | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment