Complete the function range in the following example. it should return a new array containing the integer values [lo,hi].
(Hint: remember, sizeof(int) returns the size of an object of type int in bytes. 10*sizeof(int) is equal to sizeof(A) if A were declared as int A[10];
#include <stdio.h>
#include <stdlib.h>
int *range(int lo, int hi) {
... you write this part...
}
int main(int argc, char *argv[]) {
int i;
int l = (argc > 1) ? atoi(argv[1]) : 0;
int h = (argc > 2) ? atoi(argv[2]) : 0;
int *r = range(l,h);
for (i=0; i < h-l+1; i++) printf("%d ",r[i]);
printf("\n");
return 0;
}
For example, ./range -3 5 prints out