#include <stdio.h>
#include <stdlib.h>
int main(int iics, char*argv[]){
int a,n=0,sum=0,average,highest,lowest,num[100];
for (a=1; a<iics; ++a)
sum = sum + (num[n++] = atoi(argv[a]));
printf ("The sum is %.2d \n", sum);
average = sum / n;
printf ("The average is %.2d \n", average);
highest = num[0];
lowest = num[0];
for (a = 1; a < n; ++a){
if(num[a] > highest)
highest = num[a];
if(num[a] < lowest)
lowest = num[a];
}
printf ("The highest element is %.2d \n",highest);
printf ("The lowest element is %.2d \n", lowest);
return 0;
}
1
solved How to find the largest and smallest element in C using arguments and array? [closed]