This commit is contained in:
2024-10-24 09:00:54 -07:00
commit a31344e493

41
Q1.c Normal file
View File

@@ -0,0 +1,41 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct Student {
int id;
char name[30];
double grade;
} Student;
typedef struct Node {
Student student;
struct Node* next;
} Node;
Node* newNode(const int id, const char* name, const double grade) {
Node* node = (Node*)malloc(sizeof(Node));
node->student.id = id;
strcpy(node->student.name, name);
node->student.grade = grade;
node->next = NULL;
return node;
}
void printStudents(Node* head) {
Node* current = head;
while (current != NULL) {
printf("Student ID: %d\n", current->student.id);
printf("Student Name: %s\n", current->student.name);
printf("Student Grade: %f\n", current->student.grade);
current = current->next;
}
printf("\n");
}
int main(void) {
return 0;
}