sigh, ok i still dont get it. This is a function to find the range of values in an array of integers...it is someone elses code that i am using to teach myself about arrays.
Code:
#include <stdio.h>
#define MAX 100
int spread(int b[], int size);
int main(int argc, char *argv[])
{
int n;
int count = 0;
int a[MAX];
while (count < MAX && scanf("%d", &n) != EOF)
{
a[count++] = n;
}
printf("spread was %d\n", spread(a, count));
return 0;
}
int spread(int b[], int size)
{
int lo, hi, i;
if (size == 0)
return 0;
lo = hi = b[0];
for (i = 0; i < size; i++)
{
if (b[i] > hi)
hi = b[i];
if (b[i] < lo)
lo = b[i];
}
return (hi - lo);
}
I compile this as: gcc array.c -Wall -o array
Then run it: ./array (i figure numbers go here but that didn't work)
What do i do to input the array of integers?
Thanks -Nick
[or maybe the code i am using is wrong...]