Answer to Question #208383 in C++ for Navya kala

Question #208383

Testpaper Arrangement in Decreasing Order

A system maintains a set of testpapers and arranges those papers in decreasing order either by registration number or by name.


Develop suitable algorithm and C++ code to create a generic class for maintaining the testpapers and arranging them.


Input format:


Enter the no. of testpapers,n


Enter the registration number of testpaper1


Enter the registration number of testpaper2



Enter the registration number of testpapern


Enter the name of testpaper1


Enter the name of testpaper2


Enter the name of testpaper3


Output format:


Registration number arranged in decreasing order (one in each line)


Name arranged in decreasing order (one in each line)


1
Expert's answer
2021-06-19T07:00:02-0400
#include<iostream>
#include<iomanip>
using namespace std;
int main(){

    char name[10][10];
    int regNum[10][2];
    cout<<"Enter the number of students:";
    int i,j,n;
    cin>>n;
    for(i=0;i<n;i++){
        cout<<"Name : ";
        cin>>name[i];
        cout<<"Registration number : ";
        cin>>regNum[i][0];
    }
    for(i=0;i<n;i++){
        regNum[i][1]=0;
        for(j=0;j<n;j++)
            if(regNum[i][0]<regNum[j][0])
                regNum[i][1]++;
    }
    for(i=0;i<n;i++)
        for(j=0;j<n;j++)
            if(regNum[j][1]==i)
                cout<<"Name : "<<setw(5)<<name[j]<<"  ,Registration number : "<<regNum[j][0]<<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
APPROVED BY CLIENTS