Welcome to Westonci.ca, the place where your questions are answered by a community of knowledgeable contributors. Explore our Q&A platform to find in-depth answers from a wide range of experts in different fields. Get precise and detailed answers to your questions from a knowledgeable community of experts on our Q&A platform.

Suppose we define a WaitlistEntry as follows:

typedef struct{
int iPriority; /* Priority of the student to be enrolled */
int iStudentID; /* ID of the student */
}
WaitlistEntry;

Below are different implements of a function to create a WaitlistEntry from given iPriority and iStudentID data. Some of these implementations are flawed. Identify them and describe what is wrong with them briefly:

WaitlistEntry createWL( int iPriority, int iStudentlD )
WaitlistEntry w,
w.iPriority iPriority;
w.iStudentlD iStudentlD;
return w;

a. correct
b. incorrect, leaks memory
c. incorrect, syntax error
d. incorrect, data will be overwritten by next function call


Sagot :

Answer:

You have syntax errors, but I don't know if it happened when you posted this question, nevertheless

Explanation:

Correct code:

WaitlistEntry createWL( int iPriority, int iStudentID ) { // Opening Brace

WaitlistEntry w; // Should be ; not ,

w.iPriority = iPriority;   // Assign Missing

w.iStudentID = iStudentID; // Assign Missing

return w;

} // Closing Brace

// Also note: iStudentID this actually has an 'l' which is LD. Not ID, this is why I assume these errors happened when posting the question.

We hope our answers were useful. Return anytime for more information and answers to any other questions you have. Thank you for your visit. We're dedicated to helping you find the information you need, whenever you need it. Thank you for using Westonci.ca. Come back for more in-depth answers to all your queries.