Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- int n;
- printf("Enter the size of an array: ");
- scanf("%d", &n);
- int a[n], i;
- printf("Enter the elements: ");
- for(i = 0; i < n; i++) scanf("%d", &a[i]);
- int max = a[0], min = a[0];
- for(i = 1; i < n; i++)
- {
- if(max < a[i]) max = a[i];
- if(min > a[i]) min = a[i];
- }
- printf("The maximum element is %d and the minimum element is %d\n", max, min);
- }
Add Comment
Please, Sign In to add comment