Final Assignment
Final Assignment
Source Code
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef union {
float grade;
char feedback[1000];
} StudentData;
typedef struct {
int studentNumber;
char fullName[100];
int studentID;
int dataChoice; // 1 for grade, 2 for feedback
StudentData data; // Union to store either grade or feedback
} Student;
// ID validation
validateStudentID(s);
if (found) {
printf("Student details successfully updated!\n");
} else {
printf("No student found with the provided ID.\n");
}
}
// Validate student ID
validateStudentID(&students[i]);
gatherAdditionalData(&students[i]);
}
}
int main() {
int totalStudents;
printf("Enter the number of students: ");
scanf("%d", &totalStudents);
getchar(); // Clear leftover newline
// Main menu
while (1) {
printf("\nMenu:\n");
printf("1. Display all student records\n");
printf("2. Update student information\n");
printf("3. Exit\n");
printf("Enter your choice: ");
int choice;
scanf("%d", &choice);
if (choice == 3) {
free(students);
return 0;
} else if (choice == 1) {
displayStudentRecords(students, totalStudents);
} else if (choice == 2) {
updateStudentInfo(students, totalStudents);
}
}
free(students);
}
Output:
Input Validation:
Update Feature: