Advertisement
Guest User

Untitled

a guest
Nov 19th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.68 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4.     double mx, other;
  5.     int ans = 1, input;
  6.    
  7.     printf("Write a number\n");
  8.     input = scanf("%lf", &mx);
  9.     if (input == 0 || input == EOF) {
  10.         printf("No input\nNo MIN or MAX number");
  11.         return -1;
  12.     }
  13.    
  14.     printf("Putin more numbers\n");
  15.     for (int i = 2; ; ++i) {
  16.         input = scanf("%lf", &other);
  17.         if (input == 0 || input == EOF) {
  18.             printf("End of input\n");
  19.             break;
  20.         } else if (other > mx) {
  21.             mx = other;
  22.             ans = i;
  23.         }
  24.     }
  25.    
  26.     printf("Max Number: %f\n", mx);
  27.     printf("First position: %d", ans);
  28.    
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement