Initial Commit
This commit is contained in:
BIN
example/example
Normal file
BIN
example/example
Normal file
Binary file not shown.
62
example/example.c
Normal file
62
example/example.c
Normal file
@@ -0,0 +1,62 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
// Structure to represent Ellen
|
||||
typedef struct {
|
||||
char name[20];
|
||||
int age;
|
||||
char hobby[50];
|
||||
char profession[30];
|
||||
} Person;
|
||||
|
||||
// Function to introduce Ellen
|
||||
void introduce_ellen(Person *ellen) {
|
||||
printf("Hello! My name is %s.\n", ellen->name);
|
||||
printf("I am %d years old.\n", ellen->age);
|
||||
printf("I work as a %s.\n", ellen->profession);
|
||||
printf("In my free time, I enjoy %s.\n", ellen->hobby);
|
||||
}
|
||||
|
||||
// Function to simulate Ellen's daily activity
|
||||
void ellen_daily_activity(Person *ellen) {
|
||||
printf("\n--- %s's Daily Activities ---\n", ellen->name);
|
||||
printf("Morning: %s starts her day with coffee and planning.\n", ellen->name);
|
||||
printf("Afternoon: Working hard as a %s.\n", ellen->profession);
|
||||
printf("Evening: Relaxing with %s.\n", ellen->hobby);
|
||||
}
|
||||
|
||||
// Function to update Ellen's information
|
||||
void update_ellen_info(Person *ellen, int new_age, const char *new_hobby) {
|
||||
ellen->age = new_age;
|
||||
strcpy(ellen->hobby, new_hobby);
|
||||
printf("\n%s's information has been updated!\n", ellen->name);
|
||||
}
|
||||
|
||||
int main() {
|
||||
// Create Ellen
|
||||
Person ellen;
|
||||
strcpy(ellen.name, "Ellen");
|
||||
ellen.age = 28;
|
||||
strcpy(ellen.profession, "Software Developer");
|
||||
strcpy(ellen.hobby, "reading books");
|
||||
|
||||
printf("=== Welcome to Ellen's Program! ===\n\n");
|
||||
|
||||
// Introduce Ellen
|
||||
introduce_ellen(&ellen);
|
||||
|
||||
// Show Ellen's daily activities
|
||||
ellen_daily_activity(&ellen);
|
||||
|
||||
// Update Ellen's information
|
||||
printf("\n--- One year later ---\n");
|
||||
update_ellen_info(&ellen, 29, "hiking and photography");
|
||||
|
||||
// Show updated information
|
||||
printf("\nUpdated information:\n");
|
||||
introduce_ellen(&ellen);
|
||||
|
||||
printf("\nThanks for learning about Ellen! 🌟\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user