Gokulakrishnan

Largest floating value.c

Jul 9th, 2020
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.38 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. int main()
  4. {
  5.     int n = 3,idx=0,i;
  6.     float *input = (float*) malloc(sizeof(float) * n), max = 0;
  7.     for(i = 0; i < n; i++){
  8.         scanf("%f",input+i);
  9.         float x = *(input+i) - (int)*(input+i);
  10.         if(max < x){
  11.             max = x;
  12.             idx = i;
  13.         }
  14.     }
  15.     printf("%f",*(input + idx));
  16.     return 0;
  17. }
Add Comment
Please, Sign In to add comment