Display record of all the students greater than X marks in final exam (in descending order with respect to marks obtained in final exam). The value of X will be entered by the user
i want this program without any function implemented
#include <iostream>
using namespace std;
struct student
{
char name[25];
float marks;
};
int main()
{
student st[10] = {{"James", 53},{"Dean",21},{"Mark",90},{"Mike",12},{"Gordon",99},{"Stella",5}}; /*List of students*/
float marks;
int arrSize = sizeof(s)/sizeof(s[0]);
student temp;
cout << "\nEnter marks (>X): ";
cin>>marks;
for (int i = 0; i < arrSize; i++){
int max = s[i].marks;
for (int j = i+1; j < arrSize; j++){
if(s[j].marks>max){
temp = s[i];
s[i]=s[j];
s[j]=temp;
}
}
};
cout<< "Students With Marks Above "<<marks<<" are:"<<endl;
for(int i = 0;i<arrSize;i++){
if (s[i].marks>marks){
cout<< s[i].name<<" "<<s[i].marks<<endl;
}
}
return 0;
}
Comments
Leave a comment