Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.

# Thread: Conflicting types in array function declaration

1. ## Conflicting types in array function declaration

I know this is an elementary assignment, but I'm new to this. I'm writing a program w/two functions, the first generates 10 random numbers, the second finds their average. The problem I'm having is with declaring the random function. I keep getting the error "Conflicting types for random". I don't see what my error is though. I get the error in the function declaration as well as in the function itself. Here's my code, which I think is good...does anyone have any suggestions?

Thank you very much!

#include <stdio.h>
#include <stdlib.h>
#define ARY_SIZE 10

// Function Declarations
void random (int ary[]);
double average (int ary[]);

int main (void)
{
// Local Declarations
int ary[ARY_SIZE];

// Statements
random(ary);
printf("The average of the random numbers is: %.1lf\n", average(ary));

return 0;

} // main

/* ***************************** Random ********************************
This function fills the arry with random integers, between 10 and 20.
*/

void random (int ary[])
{
// Local Definitions
int range = (20 - 10) + 1;
int i;

// Statements
for (i = 0; i < ARY_SIZE; i++)
ary[i] = rand() % range + 10;

return;
}

/* *************************** Average **********************************
This function takes the random numbers from the random function and finds
their average. It returns it to the main function as a double.
*/

double average (int ary[])
{
// Local Definitions
int i;
int sum = 0;

// Statements
for (i = 0; i < ARY_SIZE; i++)
sum += ary[i];

return ((double)sum/ARY_SIZE);
}

• random might be already defined in the header files you are including, try changing the function name and see if the error goes away.

• Thank you so much! I've spent two days trying to figure this out, and your suggestion worked perfectly. Thanks again!

•

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•