Liste des Groupes | Revenir à cl c |
Wrote a C program to mimic the stats shown on:I assume outliers is inside a function.
https://www.calculatorsoup.com/calculators/statistics/descriptivestatistics.php
My code compiles and works fine - every stat matches - except for one anomaly: when using a dataset of consecutive numbers 1 to N, all values > 40 are flagged as outliers. Up to 40, no problem. Random numbers dataset of any size: no problem.
And values 41+ definitely don't meet the conditions for outliers (using the IQR * 1.5 rule).
Very strange.
Edit: I just noticed I didn't initialize a char:
before: char outliers[100];
after : char outliers[100] = "";
And the problem went away. Reset it to before and problem came back.
Makes no sense. What could cause the program to go FUBAR at data point 41+ only when the dataset is consecutive numbers?
Also, why doesn't gcc just do you a solid and initialize to "" for you?Initialising to "" will zero the entire array. You really want the compiler to do that work, even when you're going to overwrite it anyway?
Les messages affichés proviennent d'usenet.