c++ should use new and delete, not malloc and free. the exception is if you need to use realloc, which you do not here. This is not an error, just a mixed language issue (when there is no reason otherwise, use c++ over C code).
what are you doing to see an error, just insert and display?
calculate turn looks broken. what is temp in that function?!
Line 41: You set rear->waitingtime, but that's the old value of rear, not the new one. So you're setting the waitingtime on the previous node.
It would be better to have one section of code that reads the new record into temp, and another section that inserts temp into the list:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
for (int i = 0; i < x; i++)
{
// Create and read the new record:
temp = (struct node *)malloc(sizeof(struct node));
cout << "Insert the element in queue : " << endl;
cin >> temp->data;
cout << "Enter the avg waiting time " << endl;
cin >> temp->waitingtime;
temp->next = nullptr;
// Insert temp into the list
if (rear == NULL) {
front = temp;
} else {
rear->next = temp;
}
rear = temp;
}
Lines 75-78: Your menu options don't match the values in the switch statement. Also, I suggest that you print the menu each time through the loop.