Use the while loop to aggregate students marksstored in an array. Use an enum to indicate in the array which student got which student got which mark and apply object oriented principles.
1
Expert's answer
2013-04-05T11:28:33-0400
# include <iostream> # include <string> using namespace std;
int main(){
enum mark{Fail, Pass, Exelent};
string s[20];
s[0]="e"; int m[20]; int i=0; while (1){
cout<<"Enter name: "; getline(cin, s[i], '\n'); if (s[i]=="") break;
cout<<"Enter mark : "; cin>>m[i]; i++; cin.ignore(); }
for (int j=0;j<i;j++){ for (int k=0;k<i-j-1;k++){ if ( m[k] > m[k+1] ) { string temp = s[k]; s[k] = s[k+1]; s[k+1] = temp;
int tem = m[k]; m[k] = m[k+1]; m[k+1] = tem; } }
} cout<<"sorted\n";
for (int j=0;j<i;j++){ cout<<s[j]<<" mark:"<<m[j]<<endl; }
Comments
You're welcome. We are glad to be helpful. If you really liked our service please press like-button beside answer field. Thank you!
Thank you very much. I really appreciate
Leave a comment