Question: you will get some small practice compiling and linking a program using make (and writing programs using arrays). Make sure to read the given code
you will get some small practice compiling and linking a program using make (and writing programs using arrays). Make sure to read the given code carefully, so that you understand what is being given to functions as input and what is being returned as output.
First, you are given the contents of the file array.h below (which may not be modified):
void print_array(const int nums[], const unsigned int size);
int find_min_loc(const int nums[], const unsigned int size);
and contents of the file main.c below (which also may not be modified):
#include
#include "array.h"
int main(int args, char* argv[])
{
const int vals[] = {1, 5, 3, 8, 9, 7, 0, 4};
const int size = 8;
print_array(vals, size);
printf(" ");
printf(" ");
int min_loc = find_min_loc(vals, size);
printf("The min value %d was found at index %d ",
vals[min_loc], min_loc);
return 0;
}
You will need to create the files :
array.c
Makefile
Such that when all the files are in one directory (in UNIX) typing
make
followed by
./main
Will produce the following output:
$ make
gcc -Wall -c array.c
gcc -Wall -c main.c
gcc array.o main.o -o main
$ ./main
[1, 5, 3, 8, 9, 7, 0, 4]
The min value 0 was found at index 6
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
