can't get the mode for this program. it's supposed to give me the grade that is repeated the most times, for example: if i enter 3,4,3,5,2 the mode should be 3.
please help me with this!!!!!
can't get the mode for this program. it's supposed to give me the grade that is repeated the most times, for example: if i enter 3,4,3,5,2 the mode should be 3.
please help me with this!!!!!
how is it supposed to give you three when your just outputting what i enter?
here s the code
i hope it helpsCode:#include <iostream> #include <conio.h> float most_repeated(float*); float most_repetead(float* g,int no){ float r[no]; float most_rep=0; for (int counter1=0;counter1<no;counter1++) { for (int counter2=0;counter2<no;counter2++) { if (g[counter1]==g[counter2]) r[counter1]++; } } for (int counter3=0;counter3<no;counter3++) { if (r[counter3]>most_rep) most_rep=g[counter3]; } return most_rep; } void main() { int numgrades; float *grades; cout<<"how many grades you wnat to enter: "<<endl; cin>>numgrades; grades = new float[numgrades]; for (int count = 0; count <numgrades; count++) { cout<<"grades " << (count + 1)<<":"; cin>>grades[count]; } for (int count = 0; count <numgrades; count++) { cout<<grades[count]<<" "; } cout<<endl; float The_most_repeated=most_repetead(grades,numgrades); cout<<"the most repeated grade is "<<The_most_repeated<<endl; getche(); return 0; }
Programming is a high logical enjoyable art for both programer and user !!
Don't use void main(). Use int main(). And it won't compile. You need using namespace std;, change the header to iostream.h (I don't recomend that), or use std::cout, std::cin, and std::endl.
Stupid things pop singers say
"I get to go to lots of overseas places, like Canada."
- Britney Spears
"I love what you've done with the place!"
-Jessica Simpson upon meeting the Secretary of Interior during tour of the White House