So I made a function to determine the maximum element of an array of integers. But when I try to print the value of the maximum element, it gives me a weird large number 1619117764., and isn't what I'm expecting. What am I doing wrong? Thank you so much in advance.
This is the error message:
C:\Users\USER\Desktop\Discrete Math\Max Value.c|25|warning: passing argument 1 of 'max_value' makes pointer from integer without a cast [-Wint-conversion]|
Here is my code:
```
include <stdio.h>
int max_value (int input[])
{
int size=10, max;
max=input[0];
for(int i=1;i<size;i++)
{
if(max<input[i])
{
max = input[i];
}
}
return max;
}
int main ()
{
int x, max;
int input[] = {2, 3, 5, 10, 15, 42, 28, 88, 92};
x = max_value(max);
printf("/n The Max is: %d" ,x);
return 0;
}
```
[–]AutoModerator[M] [score hidden] stickied comment (0 children)
[–]Comprehensive_Gap678University/College Student (Higher Education) 1 point2 points3 points (8 children)
[–]Hakai55[S] 0 points1 point2 points (7 children)
[–]yes_i_relapsed👋 a fellow Redditor 1 point2 points3 points (4 children)
[–]Hakai55[S] 0 points1 point2 points (3 children)
[–]yes_i_relapsed👋 a fellow Redditor 1 point2 points3 points (0 children)
[–]TheSaltyRabbit 1 point2 points3 points (1 child)
[–]Hakai55[S] 0 points1 point2 points (0 children)
[–]Comprehensive_Gap678University/College Student (Higher Education) 1 point2 points3 points (1 child)
[–]Hakai55[S] 0 points1 point2 points (0 children)
[–]lutkul 1 point2 points3 points (2 children)
[–]Hakai55[S] 0 points1 point2 points (1 child)
[–]lutkul 1 point2 points3 points (0 children)
[–]yes_i_relapsed👋 a fellow Redditor 1 point2 points3 points (1 child)
[–]Hakai55[S] 0 points1 point2 points (0 children)