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

typedef struct kw26RatingStruct{ char *NID; float degreeOfDifficulty; float dura

ID: 3604211 • Letter: T

Question

typedef struct kw26RatingStruct{

char *NID;
float degreeOfDifficulty;
float duration;
} kw26RatingStruct;

void kw26Rating();

STDERR output: Outputs the following items to STDERR, delimited by a semicolon “;”:

1. NID

2. A difficulty rating of how difficult you found this assignment on a scale of 1.0 (ridiculously easy) through 5.0 (insanely difficult).

3. Duration, in hours, of the time you spent on this assignment. The first argument to this function is the pointer to the kw26RatingStruct which is defined in the kw26.h include file. Make sure to output those items to STDERR. Each element should be terminated or delimited by a “;”.

This can not have a main() function. Just need the function kw26Rating to be made

Explanation / Answer


#include "kw26.h"

void kw26Rating(kw26RatingStruct* r)
{
fprintf(STDERR, "NID: %s; Difficulty: %.2f; Duration: %.2f; ", r->NID, r->degreeOfDifficulty, r->duration);
}

The purpose of the structure is to store your id, and details on how difficult you found this assignment and how muhc time you spent on the assignment.


Some where in your program, you should initialize the struct members and then call the function.
For example,
int main()
{
kw26RatingStruct rating;
char id[] = "ABC1112"; //your id

rating.NID = id;
rating.degreeOfDifficulty = 5; //assignment is medium difficult level
rating.duration = 3; //spent 3 hours

kw26Rating(&rating); //pass the address of the struct
}

Hope it helped.