bishalbiswas

largest element

Sep 13th, 2014
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<iostream>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int a[10];
  8. for(int i=0;i<10;i++)
  9. {
  10. scanf("%d",&a[i]);
  11. }
  12. int max=a[0];
  13. int loc=0;
  14. for(int i=0;i<10;i++)
  15. {
  16. if(max<a[i])
  17. max=a[i],loc=i+1;
  18.  
  19. }
  20. if(loc==0)
  21. printf("item not found\n");
  22. else
  23. printf("item %d found at position %d",max,loc);
  24. return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment