Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Input data into 2 Single dimension arrays called StudentID, Mobile for 10 stu

ID: 3538020 • Letter: 1

Question

1.    Input data into 2 Single dimension arrays called StudentID, Mobile for 10 students. Sort the data using StudentID, and display the data before and after sorting.


Sample Run

Input Student%u2019s ID , Mobile

2470161                56576105

2328755                96815622

2271091                59404027

2576971                52670261

2055686                82485227

2706097                52023502

2112837                92359927

2704808                88090220

2999274                74711559

2160191                76839217

Before Sorting

              Student ID           Mobile

2470161                56576105

2328755                96815622

2271091                59404027

2576971                52670261

2055686                82485227

2706097                52023502

2112837                92359927

2704808                88090220

2999274                74711559

2160191                76839217

After Sorting

Student ID           Mobile

2055686                82485227

2112837                92359927

2160191                76839217

2271091                59404027

2328755                96815622

2470161                56576105

2576971                52670261

2704808                88090220

2706097                52023502

2999274                74711559

Explanation / Answer

#include<iostream>
using namespace std;
void selectionsort(int StudentID[],int Mobile[],int size)
{
     int min,index;
for(int i=0;i<size;i++)   
{
index=i;
for(int k=i+1;k<size;k++)
{
if(StudentID[i]>StudentID[k])
{
index=k;
}
}
int temp=StudentID[i];        
StudentID[i]=StudentID[index];
StudentID[index]=temp;
int temp1 = Mobile[i];
Mobile[i]= Mobile[index];
Mobile[index] = temp1;
}
}
int main()
{
    int StudentID[10],Mobile[10];
    for(int i=0; i<10; i++)
    {
            cout << " Enter studet id " << (i+1) << " : ";
            cin >>StudentID[i];
            cout << " Enter studet Mobile " << (i+1)<< " : ";;
            cin >>Mobile[i];    
    }
    cout <<" before sorting " << endl;
    cout << " StudentID " << " " << " Mobile " <<endl;
    for(int i=0; i<10; i++)
    cout << StudentID[i] << " " << Mobile[i] <<endl;
    selectionsort(StudentID,Mobile,10);
    cout <<" After sorting " << endl;
    cout << " StudentID " << " " << " Mobile " <<endl;
    for(int i=0; i<10; i++)
    cout << StudentID[i] << " " << Mobile[i] <<endl;
   
system("pause");
return 0;
}