Answer to Question #160161 in C++ for sameed

Question #160161

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


1
Expert's answer
2021-01-31T08:01:57-0500
#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;
}

 

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog