#include <stdio.h>
struct Student {
char name [50]; // character array ‘name’ with 50 elements to store the students’ name.
int id; // integer ‘id’ to store student ID number
int academicYear; // integer ‘academicYear’ to store the academic year student is studying in
char department [50]; // character array ‘department’ with 50 elements to store the students’ department name
};
struct StudentClub {
char name [50]; // character array ‘name’ with 50 elements to store the club name;
int numOfMembers; // to store the number of students in a club;
struct Student* president; // to assign a Student structure object as the president of a club;
struct Student* vicePresident; // to assign a Student structure object as the vice president of a club;
struct Student* treasurer; // to assign a Student structure object as the treasurer of a club;
};
void displayStudentDetails(struct Student* student);
void displayClubDetails(struct StudentClub* studentCl);
void app_main(void)
{
// Initialize student structures
struct Student Student1 = { "Patrick", 24011, 1, "Electronics" };
struct Student Student2 = { "Jordan", 24029, 1, "Computer Science" };
struct Student Student3 = { "Lizzy", 24005, 1, "Science" };
struct Student Student4 = { "Rose", 24030, 1, "Modern Arts" };
struct Student Student5 = { "Kenny", 22007, 3, "Science" };
struct Student Student6 = { "Jessy", 23016, 2, "Social Science" };
struct StudentClub club1 = { "Earth Club", 40, &Student5, &Student1, &Student6 }; // Initialize club1
// Display student details
displayStudentDetails(&Student1);
displayStudentDetails(&Student2);
displayStudentDetails(&Student3);
displayStudentDetails(&Student4);
displayStudentDetails(&Student5);
displayStudentDetails(&Student6);
// Display club details
displayClubDetails(&club1);
}
// Function definitions
void displayStudentDetails(struct Student* student)
{
printf("Student Name: %s\n", student->name);
printf("Student ID: %d\n", student->id);
printf("Academic Year: %d\n", student->academicYear);
printf("Department: %s\n", student->department);
}
void displayClubDetails(struct StudentClub* studentCl)
{
printf("Club Name: %s\n", studentCl->name);
printf("Number of Members: %d\n", studentCl->numOfMembers);
printf("President: %s\n", studentCl->president->name);
printf("Vice President: %s\n", studentCl->vicePresident->name);
printf("Treasurer: %s\n", studentCl->treasurer->name);
}
Loading
esp32-s3-devkitc-1
esp32-s3-devkitc-1