#include <stdio.h>
int main(void)
{
int stats[20], i, j;
int mode, count, oldcount, oldmode;
printf("Enter 20 numbers: \n");
for (i = 0; i < 20; i++)
scanf_s("%d", &stats[i]);
oldcount = 0;
/*откриване на режима*/
for (i = 0; i < 20; i++)
{
mode = stats[i];
count = 1;
/*преброяване на появяванията на тази стойност*/
for (j = i + 1; j < 20; j++)
if (mode == stats[j])
count++;
/*ако count е по-голямо от oldcount, използване на нов режим*/
if (count > oldcount)
{
oldmode = mode;
oldcount = count;
}
}
printf("The mode is %d\n", oldmode);
return 0;
}
So basically this program should be able to find the most typed in number after entering 20 numbers... i can run it and enter 20 numbers but further it does nothing... it does not output the result (The mode is %d).