i have added a function to make selection sort to my code but i can't adjust it. i need that someone try the code and try to adjust it so can someone help me to adjust it plzzzzzzz....and try to help me in sorting in an ascending order by using the id_number thx in advance
my code is:
#include<iostream>
using namespace std;
struct student
{
int id_number;
int age;
int grade;
};
int z=1;
void input_data(struct student*data_ptr);
void output_data(struct student*data_ptr);
void selectionSort(int onestudent[] , int listLength);
void main()
{
cout << "number of students ";
cin>>z;
student *onestudent ;
onestudent = new student[z] ;
for ( int x = 0 ; x <= z-1 ; x++)
input_data(onestudent+i);
for ( int y = 0 ; y <= z-1 ; y++)
output_data(onestudent+j);
void selectionSort(int onestudent[], int x);
}
void input_data(struct student*data_ptr)
{
int k;
cout << "enter id_number :";
cin >> k;
data_ptr->id_number = k;
cout << "enter age :";
cin >> k;
data_ptr->age = k;
cout << "enter grade:";
cin >> k;
data_ptr->salary = k;
}
void output_data(struct student*data_ptr)
{
cout << "id_num = " << data_ptr->id_number<<endl;
cout << "age = " << data_ptr->age <<endl ;
cout << "grade = " << data_ptr->grade <<endl;
}
selectionSort(student onestudent[], int z)
{
for (int i = 0 ; i <= z-1 ; i++)
{
int smallestIndex;
int index;
int minIndex;
int temp;
smallestIndex = index;
for (minIndex = index;minIndex < z;minIndex++)
if (z[minIndex].id_number < z[smallestIndex].id_number)
smallestIndex = minIndex;
temp = z[smallestIndex].id_number;
z[smallestIndex].id_number = z[index].id_number;
}
}
}