Advertisement
PROFESSOR_AIH

Lowest Number and Position

Apr 19th, 2022
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.39 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4.     int x,arr[1000],i,low,pos=0;
  5.     scanf("%d",&x);
  6.     for(i=0; i<x; i++)
  7.     {
  8.         scanf("%d",&arr[i]);
  9.     }
  10.  
  11.     low=arr[0];
  12.     for(i=1; i<x; i++)
  13.     {
  14.         if(low>arr[i])
  15.         {
  16.             low=arr[i];
  17.             pos=i;
  18.         }
  19.     }
  20.     printf("Menor valor: %d\n",low);
  21.     printf("Posicao: %d\n",pos);
  22.     return 0;
  23. }
  24.  
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement