I have to write a code that accepts 5 grades and sorts them from smallest to greatest using linked list.This is what I have so far using examples from the book.
#include <iostream>
using namespace std;
struct List
{
int value;
List *next;
};
int main()
{
int num, num1,num2,num3,num4;
List *head;
cout <<"Please enter 5 grades" <<endl;
cin >>num;
cin >>num1;
cin >>num2;
cin >>num3;
cin >>num4;
head = new List;
head->value = num1;
second->next = NULL;
head->next = second;
List *second = new List;
second->value = num1;
second ->next = NULL;
head->next = second;
List *third = new List;
third->value = num2;
third->next = NULL;
head->next->next = third;
List *fourth = new List;
fourth->value = num3;
fourth->next = NULL;
head->next->next->next = fourth;
List *fifth = new List;
fifth->value = num4;
fifth->next = NULL:
head->next->next->next->next = fifth;
//Print the list
cout << "First grade is: "<<
cout << "Second grade is: "<<
cout << "Third grade is: "<<
cout << "Fourth grade is: "<<
cout << "Fifth grade is: "<<