Hotel Management System Project In C With Source Code
The Hotel Management System Project In C With Source Code is develop in C programming language, This program is adapted to provide us information on reserving rooms, book an event, check the features etc.
A Hotel Management System In C is untroublesome as it will serve the admin or user to be updated about the records without any strain and it is favored much by the people involved in the business sector. As we are aware of the busy and hectic schedule of business people, this Hotel Management System In C Language turns out to be a great relief for them.
This C Program For Hotel Management System definitely has a wide scope to minimize errors in the making of bills and it also limits the delay of delivering bills to the customers which can include taxes on the basis of their expenditure.
Watch the video here to see the full running Hotel Management System Project In C with Source Code
This Simple Hotel Management System Code In C Language also includes a downloadable Hotel Management System Project In C With Source Code for free, just find the downloadable source code below and click to start downloading.
To start creating a Hotel Management System Project In C With Source Code, make sure that you have code blocks or any platform of c language installed in your computer.
Steps on how to create a Hotel Management System Project In C With Source Code
Hotel Management System Project In C With Source Code
- Step 1: Create a new project.
First open the code blocks IDE and click “create a new project“.
- Step 2: Choose console application.
Second click the “console application” and after that click “next“.
- Step 3: Choose C language.
Third choose “C language” and click “next“.
- Step 4: Name Your Project.
Fourth name the project you’ve created and click “next” after that click “finish“.
- Step 5: The actual code.
You are free to copy the given source code below or download the downloadable source code given.
The Code Given Below Is For The Login Module
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
void login() { int a=0,i=0; char uname[10],c=' '; char pword[10],code[10]; char user[10]="user"; char pass[10]="pass"; do { system("cls"); printf("\n ************************** LOGIN FORM ************************** "); printf(" \n ENTER USERNAME:-"); scanf("%s", &uname); printf(" \n ENTER PASSWORD:-"); while(i<10) { pword[i]=getch(); c=pword[i]; if(c==13) break; else printf("*"); i++; } pword[i]='\0'; //char code=pword; i=0; //scanf("%s",&pword); if(strcmp(uname,user)==0 && strcmp(pword,pass)==0) { printf(" \n\n\n WELCOME !!!! LOGIN IS SUCCESSFUL"); break; } else { printf("\n SORRY !!!! LOGIN IS UNSUCESSFUL"); a++; getch(); } } while(a<=2); if (a>2) { printf("\nSorry you have entered the wrong username and password for four times!!!"); getch(); } system("cls"); } |
In this module which is the login module of the system.
The Code Given Below Is For The Main Module
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
int main(){ // MAIN FUNCTION int i=0; time_t t; time(&t); char customername; char choice; login(); system("cls"); while (1) // INFINITE LOOP { system("cls"); setcolor(10); for(i=0;i<80;i++) printf("-"); printf("\n"); printf(" ****************************** |MAIN MENU| ***************************** \n"); for(i=0;i<80;i++) printf("-"); printf("\n"); setcolor(10); printf("\t\t *Please enter your choice for menu*:"); printf("\n\n"); printf(" \n Enter 1 -> Book a room"); printf("\n------------------------"); printf(" \n Enter 2 -> View Customer Record"); printf("\n----------------------------------"); printf(" \n Enter 3 -> Delete Customer Record"); printf("\n-----------------------------------"); printf(" \n Enter 4 -> Search Customer Record"); printf("\n-----------------------------------"); printf(" \n Enter 5 -> Edit Record"); printf("\n-----------------------"); printf(" \n Enter 6 -> Exit"); printf("\n-----------------"); printf("\n"); for(i=0;i<80;i++) printf("-"); printf("\nCurrent date and time : %s",ctime(&t)); for(i=0;i<80;i++) printf("-"); choice=getche(); choice=toupper(choice); switch(choice) // SWITCH STATEMENT { case '1': add();break; case '2': list();break; case '3': delete1();break; case '4': search();break; case '5': edit();break; case '6': system("cls"); printf("\n\n\t *****THANK YOU*****"); printf("\n\t FOR TRUSTING OUR SERVICE"); // Sleep(2000); exit(0); break; default: system("cls"); printf("Incorrect Input"); printf("\n Press any key to continue"); getch(); } } } |
In this module which is the main module of the system.
The Code Given Below Is For The Adding Module
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
void add() { FILE *f; char test; f=fopen("add.txt","a+"); if(f==0) { f=fopen("add.txt","w+"); system("cls"); printf("Please hold on while we set our database in your computer!!"); printf("\n Process completed press any key to continue!! "); getch(); } while(1) { system("cls"); printf("\n Enter Customer Details:"); printf("\n**************************"); printf("\n Enter Room number:\n"); scanf("\n%s",s.roomnumber); fflush(stdin); printf("Enter Name:\n"); scanf("%s",s.name); printf("Enter Address:\n"); scanf("%s",s.address); printf("Enter Phone Number:\n"); scanf("%s",s.phonenumber); printf("Enter Nationality:\n"); scanf("%s",s.nationality); printf("Enter Email:\n"); scanf(" %s",s.email); printf("Enter Period(\'x\'days):\n"); scanf("%s",&s.period); printf("Enter Arrival date(dd\\mm\\yyyy):\n"); scanf("%s",&s.arrivaldate); fwrite(&s,sizeof(s),1,f); fflush(stdin); printf("\n\n1 Room is successfully booked!!"); printf("\n Press esc key to exit, any other key to add another customer detail:"); test=getche(); if(test==27) break; } fclose(f); } |
In this module which is the adding module of the system.
The Code Given Below Is For The List Module
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
void list() { FILE *f; int i; if((f=fopen("add.txt","r"))==NULL) exit(0); system("cls"); printf("ROOM "); printf("NAME\t "); printf("\tADDRESS "); printf("\tPHONENUMBER "); printf("\tNATIONALITY "); printf("\tEMAIL "); printf("\t\t PERIOD "); printf("\t ARRIVALDATE \n"); for(i=0;i<118;i++) printf("-"); while(fread(&s,sizeof(s),1,f)==1) { /*printf("ROOMNUMBER :\t%s\n",s.roomnumber); printf("NAME:\t%s\n",,s.name); printf("ADDRESS:\t%s\n",s.address); printf("PHONENUMBER:\t%s\n",s.phonenumber); printf("NATIONALITY \n");*/ printf("\n%s \t%s \t\t%s \t\t%s \t%s \t%s \t %s \t %s",s.roomnumber, s.name , s.address , s.phonenumber ,s.nationality ,s.email,s.period, s.arrivaldate); } printf("\n"); for(i=0;i<118;i++) printf("-"); fclose(f); getch(); } |
In this module which is the list module of the system that contains record of the customer.
The Code Given Below Is For The Delete Module
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
void delete1() { FILE *f,*t; int i=1; char roomnumber[20]; if((t=fopen("temp.txt","w"))==NULL) exit(0); if((f=fopen("add.txt","r"))==NULL) exit(0); system("cls"); printf("Enter the Room Number of the hotel to be deleted from the database: \n"); fflush(stdin); scanf("%s",roomnumber); while(fread(&s,sizeof(s),1,f)==1) { if(strcmp(s.roomnumber,roomnumber)==0) { i=0; continue; } else fwrite(&s,sizeof(s),1,t); } if(i==1) { printf("\n\n Records of Customer in this Room number is not found!!"); //remove("E:/file.txt"); //rename("E:/temp.txt","E:/file.txt"); getch(); fclose(f); fclose(t); main(); } fclose(f); fclose(t); remove("add.txt"); rename("temp.txt","add.txt"); printf("\n\nThe Customer is successfully removed...."); fclose(f); fclose(t); getch(); } |
In this module which is the delete module of the system, that can delete customer information.
The Code Given Below Is For The Search Module
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
void search() { system("cls"); FILE *f; char roomnumber[20]; int flag=1; f=fopen("add.txt","r+"); if(f==0) exit(0); fflush(stdin); printf("Enter Room number of the customer to search its details: \n"); scanf("%s", roomnumber); while(fread(&s,sizeof(s),1,f)==1) { if(strcmp(s.roomnumber,roomnumber)==0){ flag=0; printf("\n\tRecord Found\n "); printf("\nRoom Number:\t%s",s.roomnumber); printf("\nName:\t%s",s.name); printf("\nAddress:\t%s",s.address); printf("\nPhone number:\t%s",s.phonenumber); printf("\nNationality:\t%s",s.nationality); printf("\nEmail:\t%s",s.email); printf("\nPeriod:\t%s",s.period); printf("\nArrival date:\t%s",s.arrivaldate); flag=0; break; } } if(flag==1){ printf("\n\tRequested Customer could not be found!"); } getch(); fclose(f); } |
In this module which is the search module of the system that can search customers and its information.
The Code Given Below Is For The Edit Module
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
void edit() { FILE *f; int k=1; char roomnumber[20]; long int size=sizeof(s); if((f=fopen("add.txt","r+"))==NULL) exit(0); system("cls"); printf("Enter Room number of the customer to edit:\n\n"); scanf("%[^\n]",roomnumber); fflush(stdin); while(fread(&s,sizeof(s),1,f)==1) { if(strcmp(s.roomnumber,roomnumber)==0) { k=0; printf("\nEnter Room Number :"); gets(s.roomnumber); printf("\nEnter Name :"); fflush(stdin); scanf("%s",&s.name); printf("\nEnter Address :"); scanf("%s",&s.address); printf("\nEnter Phone number :"); scanf("%f",&s.phonenumber); printf("\nEnter Nationality :"); scanf("%s",&s.nationality); printf("\nEnter Email :"); scanf("%s",&s.email); printf("\nEnter Period :"); scanf("%s",&s.period); printf("\nEnter Arrival date :"); scanf("%s",&s.arrivaldate); fseek(f,size,SEEK_CUR); //to go to desired position infile fwrite(&s,sizeof(s),1,f); break; } } if(k==1){ printf("\n\nTHE RECORD DOESN'T EXIST!!!!"); fclose(f); getch(); }else{ fclose(f); printf("\n\n\t\tYOUR RECORD IS SUCCESSFULLY EDITED!!!"); getch(); } } |
In this module which is the edit or update module, that can edit info of customer.
Complete Source Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 |
#include<stdio.h> #include<conio.h> #include<ctype.h> #include<windows.h> #include<stdlib.h> #include<time.h> void add(); //FUNCTIONS void list(); void edit(); //GLOBALLY DECLARED FUNCTIONS N VARIABLE void delete1(); void search(); void setcolor(int ForgC) { WORD wColor; HANDLE hStdOut=GetStdHandle(STD_OUTPUT_HANDLE); CONSOLE_SCREEN_BUFFER_INFO csbi; if(GetConsoleScreenBufferInfo(hStdOut,&csbi)) { wColor=(csbi.wAttributes & 0xB0)+(ForgC & 0x0B); // SetConsoleTextAttributes(hStdOut,wColor); SetConsoleTextAttribute(hStdOut,wColor); } } void login() { int a=0,i=0; char uname[10],c=' '; char pword[10],code[10]; char user[10]="user"; char pass[10]="pass"; do { system("cls"); printf("\n ************************** LOGIN FORM ************************** "); printf(" \n ENTER USERNAME:-"); scanf("%s", &uname); printf(" \n ENTER PASSWORD:-"); while(i<10) { pword[i]=getch(); c=pword[i]; if(c==13) break; else printf("*"); i++; } pword[i]='\0'; //char code=pword; i=0; //scanf("%s",&pword); if(strcmp(uname,user)==0 && strcmp(pword,pass)==0) { printf(" \n\n\n WELCOME !!!! LOGIN IS SUCCESSFUL"); break; } else { printf("\n SORRY !!!! LOGIN IS UNSUCESSFUL"); a++; getch(); } } while(a<=2); if (a>2) { printf("\nSorry you have entered the wrong username and password for four times!!!"); getch(); } system("cls"); } struct CustomerDetails //STRUCTURE DECLARATION { char roomnumber[10]; char name[20]; char address[25]; char phonenumber[15]; char nationality[15]; char email[20]; char period[10]; char arrivaldate[10]; }s; int main(){ // MAIN FUNCTION int i=0; time_t t; time(&t); char customername; char choice; login(); system("cls"); while (1) // INFINITE LOOP { system("cls"); setcolor(10); for(i=0;i<80;i++) printf("-"); printf("\n"); printf(" ****************************** |MAIN MENU| ***************************** \n"); for(i=0;i<80;i++) printf("-"); printf("\n"); setcolor(10); printf("\t\t *Please enter your choice for menu*:"); printf("\n\n"); printf(" \n Enter 1 -> Book a room"); printf("\n------------------------"); printf(" \n Enter 2 -> View Customer Record"); printf("\n----------------------------------"); printf(" \n Enter 3 -> Delete Customer Record"); printf("\n-----------------------------------"); printf(" \n Enter 4 -> Search Customer Record"); printf("\n-----------------------------------"); printf(" \n Enter 5 -> Edit Record"); printf("\n-----------------------"); printf(" \n Enter 6 -> Exit"); printf("\n-----------------"); printf("\n"); for(i=0;i<80;i++) printf("-"); printf("\nCurrent date and time : %s",ctime(&t)); for(i=0;i<80;i++) printf("-"); choice=getche(); choice=toupper(choice); switch(choice) // SWITCH STATEMENT { case '1': add();break; case '2': list();break; case '3': delete1();break; case '4': search();break; case '5': edit();break; case '6': system("cls"); printf("\n\n\t *****THANK YOU*****"); printf("\n\t FOR TRUSTING OUR SERVICE"); // Sleep(2000); exit(0); break; default: system("cls"); printf("Incorrect Input"); printf("\n Press any key to continue"); getch(); } } } void add() { FILE *f; char test; f=fopen("add.txt","a+"); if(f==0) { f=fopen("add.txt","w+"); system("cls"); printf("Please hold on while we set our database in your computer!!"); printf("\n Process completed press any key to continue!! "); getch(); } while(1) { system("cls"); printf("\n Enter Customer Details:"); printf("\n**************************"); printf("\n Enter Room number:\n"); scanf("\n%s",s.roomnumber); fflush(stdin); printf("Enter Name:\n"); scanf("%s",s.name); printf("Enter Address:\n"); scanf("%s",s.address); printf("Enter Phone Number:\n"); scanf("%s",s.phonenumber); printf("Enter Nationality:\n"); scanf("%s",s.nationality); printf("Enter Email:\n"); scanf(" %s",s.email); printf("Enter Period(\'x\'days):\n"); scanf("%s",&s.period); printf("Enter Arrival date(dd\\mm\\yyyy):\n"); scanf("%s",&s.arrivaldate); fwrite(&s,sizeof(s),1,f); fflush(stdin); printf("\n\n1 Room is successfully booked!!"); printf("\n Press esc key to exit, any other key to add another customer detail:"); test=getche(); if(test==27) break; } fclose(f); } void list() { FILE *f; int i; if((f=fopen("add.txt","r"))==NULL) exit(0); system("cls"); printf("ROOM "); printf("NAME\t "); printf("\tADDRESS "); printf("\tPHONENUMBER "); printf("\tNATIONALITY "); printf("\tEMAIL "); printf("\t\t PERIOD "); printf("\t ARRIVALDATE \n"); for(i=0;i<118;i++) printf("-"); while(fread(&s,sizeof(s),1,f)==1) { /*printf("ROOMNUMBER :\t%s\n",s.roomnumber); printf("NAME:\t%s\n",,s.name); printf("ADDRESS:\t%s\n",s.address); printf("PHONENUMBER:\t%s\n",s.phonenumber); printf("NATIONALITY \n");*/ printf("\n%s \t%s \t\t%s \t\t%s \t%s \t%s \t %s \t %s",s.roomnumber, s.name , s.address , s.phonenumber ,s.nationality ,s.email,s.period, s.arrivaldate); } printf("\n"); for(i=0;i<118;i++) printf("-"); fclose(f); getch(); } void delete1() { FILE *f,*t; int i=1; char roomnumber[20]; if((t=fopen("temp.txt","w"))==NULL) exit(0); if((f=fopen("add.txt","r"))==NULL) exit(0); system("cls"); printf("Enter the Room Number of the hotel to be deleted from the database: \n"); fflush(stdin); scanf("%s",roomnumber); while(fread(&s,sizeof(s),1,f)==1) { if(strcmp(s.roomnumber,roomnumber)==0) { i=0; continue; } else fwrite(&s,sizeof(s),1,t); } if(i==1) { printf("\n\n Records of Customer in this Room number is not found!!"); //remove("E:/file.txt"); //rename("E:/temp.txt","E:/file.txt"); getch(); fclose(f); fclose(t); main(); } fclose(f); fclose(t); remove("add.txt"); rename("temp.txt","add.txt"); printf("\n\nThe Customer is successfully removed...."); fclose(f); fclose(t); getch(); } void search() { system("cls"); FILE *f; char roomnumber[20]; int flag=1; f=fopen("add.txt","r+"); if(f==0) exit(0); fflush(stdin); printf("Enter Room number of the customer to search its details: \n"); scanf("%s", roomnumber); while(fread(&s,sizeof(s),1,f)==1) { if(strcmp(s.roomnumber,roomnumber)==0){ flag=0; printf("\n\tRecord Found\n "); printf("\nRoom Number:\t%s",s.roomnumber); printf("\nName:\t%s",s.name); printf("\nAddress:\t%s",s.address); printf("\nPhone number:\t%s",s.phonenumber); printf("\nNationality:\t%s",s.nationality); printf("\nEmail:\t%s",s.email); printf("\nPeriod:\t%s",s.period); printf("\nArrival date:\t%s",s.arrivaldate); flag=0; break; } } if(flag==1){ printf("\n\tRequested Customer could not be found!"); } getch(); fclose(f); } void edit() { FILE *f; int k=1; char roomnumber[20]; long int size=sizeof(s); if((f=fopen("add.txt","r+"))==NULL) exit(0); system("cls"); printf("Enter Room number of the customer to edit:\n\n"); scanf("%[^\n]",roomnumber); fflush(stdin); while(fread(&s,sizeof(s),1,f)==1) { if(strcmp(s.roomnumber,roomnumber)==0) { k=0; printf("\nEnter Room Number :"); gets(s.roomnumber); printf("\nEnter Name :"); fflush(stdin); scanf("%s",&s.name); printf("\nEnter Address :"); scanf("%s",&s.address); printf("\nEnter Phone number :"); scanf("%f",&s.phonenumber); printf("\nEnter Nationality :"); scanf("%s",&s.nationality); printf("\nEnter Email :"); scanf("%s",&s.email); printf("\nEnter Period :"); scanf("%s",&s.period); printf("\nEnter Arrival date :"); scanf("%s",&s.arrivaldate); fseek(f,size,SEEK_CUR); //to go to desired position infile fwrite(&s,sizeof(s),1,f); break; } } if(k==1){ printf("\n\nTHE RECORD DOESN'T EXIST!!!!"); fclose(f); getch(); }else{ fclose(f); printf("\n\n\t\tYOUR RECORD IS SUCCESSFULLY EDITED!!!"); getch(); } } |
Run Quick Virus Scan for secure Download
Run Quick Scan for safe DownloadDownloadable Source Code
Summary
This System Project is being develop in C programming language, and this simple project can enhance the knowledge of the beginners or the students to develop their skills in programming, also this project is easy to understand the module and their variables.
Hotel Management System Project using Different Programming Languages
- Hostel Management System Project In Python With Source Code
- Hotel Management System Project In PHP With Source Code
- Hotel Management System Project Using VB.Net
- Hotel Management System Java Projects With Source Code
Recommended Books, Course, Compiler, etc.
- Best Python Books for Beginners 2021
- Best Python Course Online | Python Course Free 2021
- Best Python Compiler Online and Offline 2021
- Best Python IDE for Windows, Linux, Mac OS 2021
- Free Python Certification | Which and How to Get Best Python Certification
Related Articles
- Simple Hospital Management System In C With Source Code
- Calendar In C Programming With Source Code
- Student Record System in C with Source Code
- Employee Management System In C With Source Code
- Mini Project for Phonebook in C with Source Code
- Library Management System In C With Source Code
Inquiries
If you have any questions or suggestions about Hotel Management System In C With Source Code , please feel free to leave a comment below.