Using Structures write an interactive program in C language to create an application program for a small training company to maintain the Trainer's database. This application should be having menu options like
Creating a New Record
Reading/Listing of Records
Modify the record
Delete the record
Each Trainer record should have Trainer Name, Trainer ID, Department Name, Salary, Position, Date of Joining, etc.). The application should be designed user-friendly.
Here is a C program using structures and file handling to manage a trainer's database with options to create, read, modify, and delete records.
```c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define FILE_NAME "trainers.dat"
struct Trainer {
int id;
char name[50];
char department[50];
float salary;
char position[50];
char date_of_joining[15];
};
void addTrainer() {
FILE *file = fopen(FILE_NAME, "ab");
struct Trainer t;
printf("\nEnter Trainer ID: ");
scanf("%d", &t.id);
printf("Enter Trainer Name: ");
scanf(" %[^\n]", t.name);
printf("Enter Department Name: ");
scanf(" %[^\n]", t.department);
printf("Enter Salary: ");
scanf("%f", &t.salary);
printf("Enter Position: ");
scanf(" %[^\n]", t.position);
printf("Enter Date of Joining (DD/MM/YYYY): ");
scanf(" %[^\n]", t.date_of_joining);
fwrite(&t, sizeof(t), 1, file);
fclose(file);
printf("\nRecord added successfully.\n");
}
void listTrainers() {
FILE *file = fopen(FILE_NAME, "rb");
struct Trainer t;
if (file == NULL) {
printf("\nNo records found.\n");
return;
______ ________ _________ ____ ___.
________ ____ ________ _________ ________ ___ _______ ___ __________ _________.
_____ _________ ___ __________ _____ _____ ________.
____ ____ _______ ______ ________ _________ _________ ________.
_________ ____ ___ ___ __________.
_____ ________ __________ _______ ______ ________ _______.
________ ___ _____ __________ __________ ___ ___ ___ _________ _____ ______ __________.
_______ ______ _____ _______ ___ ____.
_______ __________ ______ _________ _____ _______ __________ _________ ______ ____ ___ ______.
____ _________ _________ _______ ____ ___ ________ ____.
________ ____ __________ _______ ______ _________ __________ ______ _________ ___.
_________ ______ ________ ___ __________ _____ _____ ___ __________ ________ ________ ___.
____ ________ ________ _________ _________ _______ _________ _________ ___ _____.
___ _______ __________ ____ __________ ___.
_______ _________ _____ __________ ____ ____ ______ _______ _____.
________ ________ _______ ___ ___ ____ ________.
_______ _______ _____ ________ _________ ________.
___ ________ ____ ________ _______ ______ __________ ________ ________ _________ ____ __________.
___ __________ ____ ________ ______ ______ ______.
___ __________ _____ ____ ________ ____ _________ _____ _________.
_______ ______ ______ _________ _______.
________ __________ __________ ________ __________ ___.
___ __________ _________ __________ _________ _____ ___ _________ _______.
_______ __________ ______ ____ ______ ___.
_____ _______ __________ ______ __________ ________.
_________ __________ _________ _______ ____ _______.
_________ ___ _______ _________ ________ ________.
______ _____ _______ ________ _______ ______ __________ ____.
__________ _________ ___ __________ __________ _________ _________ ____ ___ __________ _______ ______.
____ ________ _______ ___ __________ ________ __________ ______.
_________ ______ _____ __________ ________ ___ __________ _________.
_____ ________ ________ _______ _________.
______ _________ ____ _____ __________ _________ _______ ____ __________ _________.
________ ____ _________ _____ ________ ____ ________ __________ ________ __________ ___.
____ _________ ___ _______ _________ _________.
_______ _________ ______ ________ _____ _______.
_________ ________ _____ _____ ____ __________ _____.
___ _____ _______ _______ _________ ____ ________ ____ ___ _______.
________ _________ _____ ____ ______ ___ _____ _____ _____.
____ ______ ____ ___ __________ _____ ________ __________ ________ __________.
_____ _________ ___ ________ _______.
______ ____ ___ ___ ________ _____.
___ ______ ____ _____ ____ ________ ______ _______ _____.
___ _______ _____ _______ ____ ___ _______ _________ ____.
_____ _________ ___ ___ ____ _______ __________ ____.
____ _____ ___ ___ ________ ____ ____ ____ ________.
______ _______ _________ _________ ____ ____ ____.
__________ __________ ____ ___ ______ _________ ___ ___.
_______ ______ _______ __________ ____ ____.
_____ _____ ___ __________ ___ _____ _________ ______ ______ ____.
____ ____ ____ _______ ____ _____ ___ _____.
__________ ____ ____ _______ ___ ____ __________ _______.
_______ ________ ____ ______ ________ _________.
______ _______ _________ _________ __________ ___ ___.
______ ________ ________ ____ __________ ______ __________.
_______ _____ ___ ____ _____.
____ ______ _________ _________ _________ ____ ____.
____ __________ ___ ___ __________ ________ ________ _______ _______ ____ ________.
___ ___ __________ ______ ___ ______ ________ _____ __________ _____.
_________ ______ ______ __________ _______ __________ ________ ______ ___ ______ __________ ____.
__________ __________ ______ _______ _____ _________ ______ ____ ___.
_____ _______ _________ ____ _________ _________ ____ __________ _______ ____ _____ ____.
____ __________ _________ _____ ________ _______ ______ _______ _______ _____ _______ _____.
____ _______ ____ ________ _________ __________.
_______ ________ _______ _____ ________ _______ _________ _____ ______ ______ ____.
_________ ________ ____ ____ _____ ______ _____ ________ _________ _________.
_________ _________ ____ _______ ________ ___ ___ ____.
_______ _________ ______ ________ ______ ______ ____ _____ _________.
________ _________ ________ ___ ___ ____ ______.
_____ ___ _____ ________ _________.
_____ ________ ___ ____ ____ ___ ___ ____ _________.
_________ _______ ______ _________ _______.
___ __________ ___ _________ _________ ____ ___ ____ _________ ______ ______ ____.
__________ _________ ______ _________ ________ _____ _______ ________ ___.
______ _______ ___ ______ __________ _________ ____.
____ ______ _____ _____ ________ ______ _______.
______ _____ __________ ______ _______ __________ ____ __________.
________ ________ _____ _______ _________ ________.
__________ _____ _________ ___ _________ _________ _____ __________ ______ ___ _________.
______ _____ __________ _________ ________ ________.
________ _____ _______ ________ _______.
__________ _____ ____ ________ _______ ______ ____ ______.
______ _______ _____ ____ _______ _____ ___ _______ ______ ____ _________.
_____ ____ ___ _______ ___ ______ ________ ___.
Get Full Answer on WhatsApp