idastan97

CSCI151 L17 P1

Sep 28th, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.38 KB | None | 0 0
  1. /*
  2.  * prog.c
  3.  *
  4.  *  Created on: Sep 29, 2016
  5.  *      Author: dastan.iyembergen
  6.  */
  7.  
  8. #include <stdio.h>
  9.  
  10. int minInd(int l, double arr[]){
  11.     int i, minI;
  12.     double min;
  13.     for (i=0; i<l; i++){
  14.         if (i==0 || min>arr[i]) {
  15.             min=arr[i];
  16.             minI=i;
  17.         }
  18.     }
  19.     return minI+1;
  20. }
  21.  
  22. int main(){
  23.     double arr[5]={456, 45.2, 4688, 35.65, 12.96};
  24.     printf("%i", minInd(5, arr));
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment