Please help with this. I need to write a program #include<stdio.h> void main() {
ID: 3679992 • Letter: P
Question
Please help with this. I need to write a program
#include<stdio.h>
void main() { double product = 1, List[10];
int i, N;
printf("Enter the length of your array (Ranging from 1 to 10): ");
scanf("%d", &N); // Assumes integer value is entered
printf("Enter each element of your array separated by space: ");
for(i = 0; i < N; i++) {
if(scanf("%lf", &List[i]) == EOF)
break; }
for(i = 0; i < N; i++)
product*=List[i];
printf("Product of All Entries is %lf", product); }
Pointers can be used as function arguments when we want to return more than one value from the function. Using the above program as a starting point, write a program that determine the maximum and minimum values from a number array entered by the user using the following function prototype statement: void MaxMin(double List[], double *Max, double *Min)
Explanation / Answer
#include <stdio.h>
#include <file.h>
int main()
{
FILE *fp;
int num, min, max,count;
sensor = fopen("maxmin.txt", "r");
if (fp != NULL)
{
for (sum = count = first = 0;
fscanf(sensor, "%d", &num) == 1; sum += num, ++count)
if (!first)
{
min = max = num; first = 1;
}
else if (num > max) max = num;
else if (num < min) min = num;
fclose(fp);
printf("count = %d, min = %d, max = %d, sum = %d, avg = %.1lf ",
count, min, max, sum, sum / (double) count);
}
else
{
printf("Unable to read file" );
}
return 0;
}