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

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%

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));

}

 

main()
{
int n, i;
printf("How many numbers to be generated (max 100) ? ");
scanf_s("%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 */
Transcribed Image Text:main() { int n, i; printf("How many numbers to be generated (max 100) ? "); scanf_s("%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 */
Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY