From: Andrey Miroshnikov Date: Wed, 8 Nov 2023 16:17:59 +0000 (+0000) Subject: Adding fortran C example for Shriya, bug #676 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=83b66a3036cb1a7dd28d4d3b9d7edfd7398c7624;p=openpower-isa.git Adding fortran C example for Shriya, bug #676 --- diff --git a/maxloc/Makefile b/maxloc/Makefile new file mode 100644 index 00000000..813bab62 --- /dev/null +++ b/maxloc/Makefile @@ -0,0 +1,10 @@ +.PHONY: all clean + +all: maxloc + +maxloc: maxloc.c + gcc maxloc.c -o maxloc + #gcc -Os -mno-vsx -mno-altivec maxloc.c -o maxloc + +clean: + rm -rf maxloc diff --git a/maxloc/maxloc.c b/maxloc/maxloc.c new file mode 100644 index 00000000..8d3d4a7a --- /dev/null +++ b/maxloc/maxloc.c @@ -0,0 +1,36 @@ +#include +#include +//#include +int m2(int * const restrict a, int n) +{ + int m, nm; + int i; + + m = INT_MIN; + nm = -1; + i=0; + while (i m) { + m = a[i]; + nm = i; + } + i++; + } + return nm; +} + +/*Testbench*/ + +int main() +{ + + int arr[]= {5,2,8,1,3,7,9,4}; + int size = sizeof(arr) / sizeof(arr[0]); + int result = m2(arr, size); + + printf("Index of the maximum value in an array is: %d\n", result); + return 0; + +}