Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 18

Final Report Sec: K22MP

Title: Courier Management System

As a Pracircal work for Course

C-Programming (CSE 101)


By

Sr. No. Registration Name of Students Roll No Total Marks Signature


No Marks Obtained
1 12203772 Gillela Krishna Koshik Reddy 9

2 12203779 Vivek Kumar Vinay 10

3 12211893 Rahul Chand 11

4 12212225 Venkat Pramod Papani 12

Submitted To Chanan Singh,


Associate Professor
Lovely Professional University
Jalandhar, Punjab, India.

Delivered by: Received by:


Name of the student: Name of the faculty:Chanan Singh
Reg. No.: UID:22235
Signature: Signature:
Description of the project
Through this project user can manage the different types of courier. User will first
create the database for couriers and then after that certain operations can be
performed depending upon the requirement of user. 
The modules included in the code are:

1. Insert module: This module is responsible for inserting new data into the system. In the context
of a courier management system, this could include information about new packages, delivery addresses,
or customers. The insert module would typically prompt the user for the relevant information, validate it for
correctness and completeness, and then store it in the system's database.
2. Display module: The display module is responsible for retrieving and displaying data from the
system. In the context of a courier management system, this module could be used to display information
about existing packages, delivery schedules, or customer accounts. The display module would typically
allow the user to search for specific records, filter records by certain criteria, and sort records based on
different fields.

3. Search module: The search module is used to retrieve specific records from the system's
database. In the context of a courier management system, this module could be used to search for
specific packages, customer accounts, or delivery schedules. The search module would typically
allow the user to enter search criteria, such as a package ID or customer name, and then retrieve
all records that match the specified criteria.
4. Delete/Update module: The delete/update module is responsible for modifying or
removing existing records from the system's database. In the context of a courier management
system, this module could be used to update the status of a package, change a delivery schedule,
or delete a customer account. The delete/update module would typically prompt the user for the
relevant information and then make the necessary changes to the database.

5. Sort module: The sort module is used to sort records in the system's database based on
different fields. In the context of a courier management system, this module could be used to sort
packages by delivery date, customers by name, or delivery schedules by route. The sort module
would typically allow the user to select a field to sort by, such as a package's delivery date, and
then display the records in ascending or descending order based on that field.
#include <stdio.h>

#include <stdlib.h>

#include <string.h>

// Define courier structure

struct Courier {

char name[50];

int id;

char address[100];

char phone[20];

};

//INSERT MODULE

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct Courier {
char name[50];
char address[100];
char phone[20];
char email[50];
};

int main() {
struct Courier courier;
FILE *fp;
fp = fopen("courier_data.txt", "a");

if(fp == NULL) {
printf("Error opening file!\n");
exit(1);
}

printf("Enter Name:");
// fgets(courier.name, 50, stdin);
fscanf(stdin, "%49[^\n]%*c", courier.name);
printf("Enter address: ");
// fgets(courier.address, 100, stdin);
fscanf(stdin, "%99[^\n]%*c", courier.address);
printf("Enter phone: ");
// fgets(courier.phone, 20, stdin);
fscanf(stdin, "%19[^\n]%*c", courier.phone);
printf("Enter email: ");
// fgets(courier.email, 50, stdin);
fscanf(stdin, "%49[^\n]%*c", courier.email);

fprintf(fp, "\n%s %s %s %s\n", courier.name, courier.address, courier.phone, courier.email);


printf("Courier data inserted successfully.\n");
fclose(fp);
   return 0;
}

Output of Insert Module


//DISPLAY MODULE

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct Courier {
char name[50];
char address[100];
char phone[20];
char email[50];
};

int main() {
struct Courier courier;
FILE *fp;
fp = fopen("courier_data.txt", "r");

if(fp == NULL) {
printf("Error opening file!\n");
exit(1);
}

printf("Courier data:\n");
printf("--------------------------------------------------------------------\n");
printf("Name\t\tAddress\t\tPhone\t\tEmail\n");
printf("--------------------------------------------------------------------\n");

while(fscanf(fp, "%s %s %s %s\n", courier.name, courier.address, courier.phone,


courier.email) != EOF) {
printf("%-15s\t%-15s\t%-10s\t%s\n", courier.name, courier.address, courier.phone,
courier.email);
}
printf("--------------------------------------------------------------------\n");
fclose(fp);
   return 0;
}
Output of Display Module

//SEARCH MODULE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct Courier {
char name[50];
char address[100];
char phone[20];
char email[50];
};

int main() {
struct Courier courier;
char search_name[50];
FILE *fp;
fp = fopen("courier_data.txt", "r");

if(fp == NULL) {
printf("Error opening file!\n");
exit(1);
}

printf("Enter name to search: ");


fgets(search_name, 50, stdin);
search_name[strcspn(search_name, "\n")] = '\0';

printf("Courier data for '%s':\n", search_name);


printf("--------------------------------------------------------------------\n");
printf("Name\t\tAddress\t\tPhone\t\tEmail\n");
printf("--------------------------------------------------------------------\n");

int found = 0;

while(fscanf(fp, "%s %s %s %s\n", courier.name, courier.address, courier.phone,


courier.email) != EOF) {
if(strcmp(courier.name, search_name) == 0) {
printf("%-15s\t%-15s\t%-10s\t%s\n", courier.name, courier.address, courier.phone,
courier.email);
found = 1;
}
}

if(!found) {
printf("No data found for '%s'\n", search_name);
}

printf("--------------------------------------------------------------------\n");
fclose(fp);
   return 0;
}
Output of Search Module

//DELETE/UPDATE MODULE

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

struct Courier {

char name[50];

char address[100];

char phone[20];

char email[50];

};
int main() {

struct Courier courier;

char search_name[50], new_name[50], new_address[100], new_phone[20], new_email[50];

FILE *fp, *temp_fp;

fp = fopen("courier_data.txt", "r");

temp_fp = fopen("temp_courier_data.txt", "w");

if(fp == NULL || temp_fp == NULL) {

printf("Error opening file!\n");

exit(1);

int option, found = 0;

printf("Enter option:\n1 - Delete data\n2 - Update data\nOption: ");

scanf("%d", &option);

if(option == 1) {

printf("Enter name to delete: ");

scanf("%s", search_name);

while(fscanf(fp, "%s %s %s %s\n", courier.name, courier.address, courier.phone,


courier.email) != EOF) {

if(strcmp(courier.name, search_name) != 0) {
fprintf(temp_fp, "%s %s %s %s\n", courier.name, courier.address, courier.phone,
courier.email);

} else {

found = 1;

if(!found) {

printf("No data found for '%s'\n", search_name);

} else {

printf("Data deleted successfully for '%s'\n", search_name);

} else if(option == 2) {

printf("Enter name to update: ");

scanf("%s", search_name);

while(fscanf(fp, "%s %s %s %s\n", courier.name, courier.address, courier.phone,


courier.email) != EOF) {

if(strcmp(courier.name, search_name) != 0) {

fprintf(temp_fp, "%s %s %s %s\n", courier.name, courier.address, courier.phone,


courier.email);

} else {

found = 1;

printf("Enter new name: ");


scanf("%s", new_name);

printf("Enter new address: ");

scanf(" %[^\n]", new_address);

printf("Enter new phone number: ");

scanf("%s", new_phone);

printf("Enter new email address: ");

scanf("%s", new_email);

fprintf(temp_fp, "%s %s %s %s\n", new_name, new_address, new_phone, new_email);

printf("Data updated successfully for '%s'\n", search_name);

if(!found) {

printf("No data found for '%s'\n", search_name);

} else {

printf("Invalid option\n");

exit(1);

fclose(fp);

fclose(temp_fp);
remove("courier_data.txt");

rename("temp_courier_data.txt", "courier_data.txt");

   return 0;

Output of Delete/ Update Module.

//SORT MODULE
#include <stdio.h>

#include <stdlib.h>

#include <string.h>

struct Courier {

char name[50];

char address[100];

char phone[20];

char email[50];

};

int main() {

struct Courier courier[100];

int i = 0, j, n;

FILE *fp;

fp = fopen("courier_data.txt", "r");

if(fp == NULL) {

printf("Error opening file!\n");

exit(1);

while(fscanf(fp, "%s %s %s %s\n", courier[i].name, courier[i].address, courier[i].phone,


courier[i].email) != EOF) {

i++;
}

n = i;

for(i = 0; i < n; i++) {

for(j = i+1; j < n; j++) {

if(strcmp(courier[i].name, courier[j].name) > 0) {

struct Courier temp = courier[i];

courier[i] = courier[j];

courier[j] = temp;

fclose(fp);

fp = fopen("courier_data.txt", "w");

for(i = 0; i < n; i++) {

fprintf(fp, "%s %s %s %s\n", courier[i].name, courier[i].address, courier[i].phone,


courier[i].email);

fclose(fp);
printf("Data sorted successfully\n");

   return 0;

Output Of Short Module

Unsorted data
Sorted data
DFD (Data Flow Diagram)

Level 0:

Level 1:

You might also like