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

This is a C coding excesise. Thank you for your time. Ask the user how many numb

ID: 3874736 • Letter: T

Question

This is a C coding excesise. Thank you for your time.

Ask the user how many numbers they would like generated. Your program will then generate that many numbers (between 0 and 1000) into an array of the same size. Find the smallest and largest numbers in the array, printing out the values and locations of those numbers in the array. Then, find the sum and average of the numbers in the array. Finally, print out the entire array to verify. Requirements: *x You MUST use functions where appropriate! Output MUST be formatted as below (numbers, spacing, etc.) Count the spaces, make sure it's correct. Make sure you include both 0 and 1000 in your random generation

Explanation / Answer

/** * C program to find maximum and minimum element in array */ #include <stdio.h> #define MAX_SIZE 100 // Maximum array size int main() { int arr[MAX_SIZE]; int i, max, min, size; /* Input size of the array */ printf("Enter size of the array: "); scanf("%d", &size); /* Input array elements */ printf("Enter elements in the array: "); for(i=0; i<size; i++) { scanf("%d", &arr[i]); } /* Assume first element as maximum and minimum */ max = arr[0]; min = arr[0]; /* * Find maximum and minimum in all array elements. */ for(i=1; i<size; i++) { /* If current element is greater than max */ if(arr[i] > max) { max = arr[i]; } /* If current element is smaller than min */ if(arr[i] < min) { min = arr[i]; } } /* Print maximum and minimum element */ printf("Maximum element = %d ", max); printf("Minimum element = %d", min); return 0; }

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