You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
668 B
43 lines
668 B
/*
|
|
* pr_07.c
|
|
*
|
|
* Created on: Jun 10, 2013
|
|
* Author: delmadord
|
|
*/
|
|
|
|
// SHOULD WORK WITH POINTER ARITHMETIC BUT I MADE NO CHANGES
|
|
// SINCE maxmin.c
|
|
|
|
#include <stdio.h>
|
|
|
|
#define N 10
|
|
|
|
void max_min(int a[], int n, int *max, int *min);
|
|
|
|
int main(void) {
|
|
int b[N], i, big, small;
|
|
|
|
printf("Enter %d numbers: ", N);
|
|
for (i = 0; i < N; i++)
|
|
scanf("%d", &b[i]);
|
|
|
|
max_min(b, N, &big, &small);
|
|
|
|
printf("Largest: %d\n", big);
|
|
printf("Smallest: %d\n", small);
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
void max_min(int a[], int n, int *max, int *min) {
|
|
int i;
|
|
|
|
*max = *min = a[0];
|
|
for (i = 1; i < n; i++) {
|
|
if (a[i] > *max)
|
|
*max = a[i];
|
|
else if (a[i] < *min)
|
|
*min = a[i];
|
|
}
|
|
}
|
|
|