Advertisement
arindam143

maximumValue.c

Aug 17th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(int argc, string argv[])
  4. {
  5. int i;
  6. int array[]={1, 10, 2, 18, 5};
  7. int max=array[0];
  8. int pos=0;
  9.  
  10. int arraySize=sizeof(array)/sizeof(int);
  11. printf("Array Size= %d",arraySize);
  12.  
  13. for(i=1; i<arraySize; i++)
  14. {
  15. if(array[i]>max)
  16. {
  17. max=array[i];
  18. pos=i;
  19. }
  20. }
  21.  
  22. printf("\nMaximum Value= %d", max);
  23. printf("\nIts position= %d",pos+1);
  24.  
  25. return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement