User:Karl Dickman/Sandbox
From Wikipedia, the free encyclopedia
- include <begin.h>
int main() {
double a,l[1001],m[1000],s[1000],i,z; outputstring("Enter the scores for the respective individuals in the class. To terminate the sequence, enter a negative score.\n"); z=0;s[0]=0; while(z<=1000) {l[z]=0;z++;} z=0; while(s[z]>=0) { outputstring("Enter score: "); inputdouble(s[z+1]); z++; } z=0; while(s[z]>=0) { z++; i=0; while(i<=1000) { if(s[z]==i) {l[i]=l[i]+1;} i++; } } i=0;a=-1; while(i<=1000) { if(l[i]>a) { a=l[i]; m[0]=i; z=0; while(z<1000) {
z++; m[z]=-1;
} z=1; } else { if(l[i]==a) {
m[z]=i; z++;
} } i++; } outputstring("The mode(s) of the set are:\n"); z=0; while(z<1000) { if(m[z]!=-1) { outputdouble(m[z]); outputstring("\n"); } z++; }
}