Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello there, I got 1 questions with programming c. I am learning the basic of it

ID: 3600447 • Letter: H

Question

Hello there, I got 1 questions with programming c. I am learning the basic of it, only have studio.h, so i wonder if you can teach me in sample method

1.Write a void function that takes 3 arguments:

An int array.

An int representing the size of the array.

A pointer to an int where you should store the largest value in the array.

(-----------------same with above-------------) smallest value in the array.

And the array will at least be of size one.

i even do not know why he said 3 arguments while there are 4 sentences listed

many thanks

Explanation / Answer

#include <stdio.h>
void maxNumber(int a[], int size, int *m) {
int i;
*m = a[0];
for(i=0;i<size;i++) {
if(a[i] > *m){
*m = a[i];
}
}
}
void minNumber(int a[], int size, int *m) {
int i;
*m = a[0];
for(i=0;i<size;i++) {
if(a[i] < *m){
*m = a[i];
}
}
}
int main()
{
int a[10] = {4,5,6,1,2,3,9,8,0,7};
int max, min;
maxNumber(a, 10, &max);
minNumber(a, 10, &min);
printf("Max: %d ",max);
printf("Min: %d ",min);
return 0;
}

Output:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote