fix: possible segmentation faults in numerical_methods/mean.c (#805)

* fixed possible segmentation fault

Fixed possible segmentation fault when no arg is supplied

* Update mean.c

various small changes to print statements.
This commit is contained in:
Satbek Abdyldayev 2021-02-24 00:36:43 +06:00 committed by GitHub
parent 8e03e35c80
commit 28fc15c65b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,9 +18,10 @@ int main(int argc, char **argv)
fprintf(stderr, "Maximum %d!\n", MAX_LEN);
return 1;
}
a = (int *)malloc(n * sizeof(int));
}
a = (int *)malloc(n * sizeof(int));
printf("Random Numbers Generated are: ");
for (i = 0; i < n; i++)
{
@ -33,7 +34,7 @@ int main(int argc, char **argv)
mean = sum / (float)n;
printf("\nMean: ");
printf("%f", mean);
printf("%f\n", mean);
free(a);
return 0;