How can I declare on top of my code a function that takes an array of ints as argument?
Thank you.

I get an error from this code below :

//Finding the minimum value in an array

#include <stdio.h>

int minimum (int values[10]);



int mimimum (int values[10])
{
	int minValue, i;
	
	minValue = values[0];
	
	for (i = 1; i < 10; ++i)
		if (values[i] < minValue)
			minValue = values[i];
	
	return minValue;
}


int main (int argc, const char * argv[]) {
    // insert code here...
    int scores[10], i, minScore;
	
	
	printf("Enter 10 scores\n");
	
	for (i = 0; i < 10; ++i)
		scanf("%i", &scores[i]);
	
	minScore = minimum(scores);
	printf("\nMinimum score is %i\n", minScore);
	
	return 0;
}

Am I doing something wrong?

Well, it'd look more like this:

#include <stdio.h>

int minimum (int values[]);



int mimimum (int values[])
{
    int minValue, i;

    minValue = values[0];

    for (i = 1; i < 9; ++i) /* Index starts at zero, zo 10 - 1 = 9 indexes. */
        if (values[i] < minValue)
            minValue = values[i];

    return minValue;
}


int main (int argc, const char * argv[]) {
    // insert code here...
    int scores[10], i, minScore;


    printf("Enter 10 scores\n");

    for (i = 0; i < 9; ++i) /* Index starts at 0, so 10 - 1 = 9 indexes. */
        scanf("%i", &scores[i]);

    minScore = minimum(scores);
    printf("\nMinimum score is %i\n", minScore);

    return 0;
}

The problem was the letter m in minimum function.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.