0

My professor uses this site (e-olymp.com) that automatically grades your solution in % For this homework we have to use pointers to solve these tasks. I had a problem with this one:

The array of real numbers is given. Calculate the twice value of the minimum element in array.

Input First line contains the number n (n ≤ 100) of elements in array. Second line contains n real numbers - the elements of array. Each value does not exceed 100 by absolute value.

Output Print the twice value of the minimum element in array with 2 decimal digits.

My solution, works perfectly fine in compiler but gives 0%, idk where is the mistake, could you take a look at this one?

#include<stdio.h>
#include <malloc.h>
int z, x;
double fx;
int main(void){
    double *c = (double *)malloc(x*sizeof(double));
    scanf("%d", &x);
    fx=100;
    for(z=0; z<x; z++){
        scanf("%lf", c+z);
        if(fx>*(c+z)) fx=*(c+z); 
    }
    printf("%.2lf", fx*2);
    free(c);
    return 0;
}
Hunter
  • 1

0 Answers0