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

I need help writing this c-program...the code currently prints outthe sum of the

ID: 3618106 • Letter: I

Question

I need help writing this c-program...the code currently prints outthe sum of the arrays and I need to find the minimum value from thelist of inputted numbers. It currently prints out the maximum valuefor some reason...even if I switch theif(x[i]<temp)...Thanks.

Also how would I change the program to run it like this....
Write a program to first populate an array of size 11 and then findthe medium of the array elements.    

/*
Write a program to first populate an array of size 10 and then findthe minimum number in the array.      
*/
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    double x[10];
    int i;
    double sum = 0;
    double temp;
  
    temp = x[0];
   
    for(i=0;i<10;i++){
        printf("Enter a number:");
        scanf("%lf",&x[i]);
        sum += x[i];
       
        if(x[i] > temp)
           temp =x[i];
    }

    printf(" The total number is %3.2f ",sum);
    printf("The minimum number is %3.2f ",temp);
   
    system("pause");
    return(0);
}

Explanation / Answer

When you first do temp = x[0];. Since you haven't initialized xarray it has garbage values so you shouldn't go that way. A way tofix this is just temp = 0. Here's how i did it. #include #include int main(void) {     double x[10];     int i;     double sum = 0;     double temp;     for(i=0;i