In the following code there is an error as shown in the picture..? What is the problem and the solution? The code: (by C) #include #include #include /* mina function define */ int mina(int arr[],int n) { int min=arr[0]; int i; for(i=0;iarr[i]) { min=arr[i]; } } /* return to main */ return min; } /* maxa function define */ int maxa(int arr[],int n) { int max=0; int i; for(i=0;i
In the following code there is an error as shown in the picture..?
What is the problem and the solution?
The code: (by C)
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
/* mina function define */
int mina(int arr[],int n)
{
int min=arr[0];
int i;
for(i=0;i<n;i++)
{
if(min>arr[i])
{
min=arr[i];
}
}
/* return to main */
return min;
}
/* maxa function define */
int maxa(int arr[],int n)
{
int max=0;
int i;
for(i=0;i<n;i++)
{
if(max<arr[i])
{
max=arr[i];
}
}
/* return to main */
return max;
}
/* printa function define */
void printa(int arr[],int n)
{
int i;
for(i=0;i<n;i++)
{
printf("%d %d\n",(i+11),arr[i]);
}
}
main()
{
int n,i;
printf("How many numbers to be generated (max 100) ? ");
scanf("%d",&n);
/* Determining length of array */
int arr[n];
/* random values from 1 to 100 */
srand(time(NULL));
for(i=0;i<n;i++)
{
arr[i]=(rand()%100+1);
}
/* Function calling statements */
printa(arr,n);
printf("Minimum Number: %d\n",mina(arr,n));
printf("Maximum Number: %d\n",maxa(arr,n));
}
Step by step
Solved in 4 steps with 1 images