Mini project Department Store System using C
destination source:https://www.programming-techniques.com/?p=2362
This mini-project features department stores using the C Programming language. The project consists of the following features
- Calculate Bill
- Add Goods
- Edit Goods
- Display All
- Search using Code, Rate and Quantity
- Delete Goods
- Exit from program
This project is a learning milestone for a beginner who wants to step into programming in C with the help of projects. If you are looking for other mini-projects, follow the link below:-
Here is List of Mini projects in C
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 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 | #include<stdio.h> #include<conio.h> #include<stdlib.h> #include<string.h> #include<ctype.h> #include<windows.h> #define ANS 15 #define ACS 4 COORD coord={0,0}; // this is global variable //center of axis is set to the top left cornor of the screen void gotoxy(int x,int y) { coord.X=x; coord.Y=y; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord); } /*declaration of checking functions*/ void c_code(char[]); int check(char[]); /*structure declaration*/ typedef struct{ char name[ANS],code[ACS]; float rate; int quantity; }rec; rec item; /*declaration of display functions*/ void curser(int); void dbill(); void d_mainmenu(); void display(rec *,int,int); void window(int,int,int,int); void dis_con(); void d_search(); void highlight(int,int); /*declaration of main menu functions*/ void bill() ; void edit(); void add(); void del(); void exit(); /*declaration of display submenu functions*/ void d_code(); void d_rate(); void d_quan(); void d_all(); /*start of main*/ int main() { d_mainmenu(); return 0; } void d_mainmenu() { int i; char ch; const char *menu[]={" Calculate Bill"," Add Goods"," Edit Goods"," Display All "," Search", " Delete Goods"," Exit"}; system("cls"); //textbackground(11); //textcolor(0); //_setcursortype(_NOCURSOR); window(25,50,20,32); gotoxy(33,18);printf("MAIN MENU"); for (i=0;i<=6;i++){ gotoxy(30,22+i+1);printf("%s\n\n\n",menu[i]);} curser(7); } void d_search() { char ch; int i; const char *menu[]={" By Code"," By Rate"," By Quantity"," Back to main menu"}; system("cls"); //textbackground(11); //textcolor(0); window(25,50,20,32); gotoxy(33,18);printf("SEARCH MENU"); for (i=0;i<=3;i++){ gotoxy(30,22+i+1);printf("%s\n\n\n",menu[i]);} curser(4); } /*function for cursor movement*/ void curser(int no) { int count=1; char ch='0'; gotoxy(30,23); while(1){ switch(ch){ case 80: count++; if (count==no+1) count=1; break; case 72: count--; if(count==0) count=no; break; } highlight(no,count); ch=getch(); if(ch=='\r'){ if(no==7){ if (count==1) bill() ; else if(count==2) add(); else if(count==3) edit(); else if (count==4) d_all(); else if (count==5) d_search(); else if (count==6) del(); else exit(0); } if(no==4){ if (count==1) d_code(); else if (count==2)d_rate(); else if (count==3) d_quan(); else d_mainmenu(); } } } } void highlight(int no,int count) { if (no==4){ //textbackground(11); //textcolor(0); gotoxy(30,23);printf(" By Code "); gotoxy(30,24);printf(" By Rate "); gotoxy(30,25);printf(" By Quantity "); gotoxy(30,26);printf(" Back to main menu"); //textcolor(0); //textbackground(2); switch (count) { case 1: gotoxy(30,23); printf(" - By Code "); break; case 2: gotoxy(30,24); printf(" - By Rate "); break; case 3: gotoxy(30,25); printf(" - By Quantity "); break; case 4: gotoxy(30,26); printf(" - Back to main menu"); break; } } if(no==7){ //textbackground(11); //textcolor(0); gotoxy (30,23);printf(" Calculate Bill "); gotoxy (30,24);printf(" Add Goods "); gotoxy (30,25);printf(" Edit Goods "); gotoxy (30,26);printf(" Display All "); gotoxy (30,27);printf(" Search "); gotoxy (30,28);printf(" Delete Goods "); gotoxy (30,29);printf(" Exit "); //textcolor(0); //textbackground(2); switch(count){ case 1: gotoxy (30,23); printf(" - Calculate Bill "); break; case 2: gotoxy (30,24); printf(" - Add Goods "); break; case 3: gotoxy (30,25); printf(" - Edit Goods "); break; case 4: gotoxy (30,26); printf(" - Display All "); break; case 5: gotoxy (30,27); printf(" - Search "); break; case 6: gotoxy (30,28); printf(" - Delete Goods "); break; case 7: gotoxy (30,29); printf(" - Exit "); break; } } } void bill() { char x[4]={0}; int j=29,q=0,size=0,i=1; float total=0,gtotal=0; FILE *file; file=fopen("record.txt","r+b"); rewind(file); system("cls"); dbill(); gotoxy(26,15);printf("enter \"end\" to finish input"); while(1){ gotoxy(25,18);printf(" "); gotoxy(25,19);printf(" "); gotoxy(25,18);printf("enter item code:"); scanf("%s",x); if(strcmp(x,"end")==0) break; gotoxy(25,19);printf("enter quantity:"); scanf("%d",&q); rewind(file); while(fread(&item,sizeof(item),1,file)){ if((strcmp(item.code,x)==0)){ total=item.rate*q; gotoxy(11,j);printf("%4d",i); printf("%9s",item.name); printf("%13d",q); printf("%15.2f",item.rate); printf("%13.2f",total); gtotal=gtotal+total; size=sizeof(item); item.quantity=item.quantity-q; j+=2; i++; fseek(file,-size,SEEK_CUR);fwrite(&item,sizeof(item),1,file); break; } } } if(gtotal!=0){ gotoxy(30,j+5); printf("TOTAL AMOUNT = NRs. %6.2f",gtotal); } fclose(file); getch(); d_mainmenu(); } /*function to display bill window*/ void dbill() { int i; gotoxy(20,10); //; for (i=1;i<=10;i++) printf("*"); printf(" * FASHION WEAR * "); for (i=1;i<=10;i++) printf("*"); printf("\n\n"); gotoxy(30,11);printf("Departmental Store"); //textcolor(1); gotoxy(32,25);printf("CUSTOMER'S BILL") ; //textcolor(8); gotoxy(13,27);printf("SN. Item Name Quantity Rate Total"); } /*function to add records*/ void add () { FILE *file; char y[ACS],x[12]; system("cls"); //textbackground(11); //textcolor(0); gotoxy(25,25);printf("Enter new record(Y/N)?"); while(toupper(getche())=='Y'){ system("cls"); file=fopen("record.txt","ab"); c_code(y); strcpy(item.code,y); gotoxy(22,28);printf("Enter rate of the item:"); scanf("%f",&item.rate); gotoxy(22,30);printf("Enter quantity of the item:"); scanf("%d",&item.quantity); gotoxy(22,32);printf("Enter name of the item:"); scanf("%s",item.name); fseek(file,0,SEEK_END);fwrite(&item,sizeof(item),1,file); fclose(file); gotoxy(22,34);printf("Enter new record(Y/N)?"); } d_mainmenu(); } /*function to check availability of code*/ void c_code(char y[]) { int flag; FILE *file; file=fopen("record.txt","rb"); while(1){ system("cls"); window(20,58,23,36); gotoxy(32,18);printf(" ADD ARTICLES ") ; flag=1; rewind(file); gotoxy(22,25);printf("Enter new code of the article:"); scanf(" %[^\n]",y); while(fread(&item,sizeof(item),1,file)==1){ if (strcmp(y,item.code)==0){ flag=0; gotoxy(26,30);printf("code already exists"); gotoxy(29,32);printf("enter again");getch(); break; } } if (flag==1) break; } } /*function for editing*/ void edit() { int flag=0,choice; char x[ACS],y[ACS]; FILE *file; int size; system("cls"); //textcolor(0); //textbackground(11); window(20,63,20,46); gotoxy(35,18);printf("EDIT RECORDS"); ; gotoxy(25,23);printf("enter item code: "); scanf("%s",x); flag=check(x); if(flag==0){ file=fopen("record.txt","r+b"); rewind(file); while (fread(&item,sizeof (item),1,file)){ if(strcmp(item.code,x)==0){ //textcolor(0); gotoxy(25,27);printf("name = %s",item.name); gotoxy(25,28);printf("code = %s",item.code); gotoxy(25,29);printf("rate = %g",item.rate); gotoxy(25,30);printf("quantity = %d",item.quantity); gotoxy(25,32);; printf("do you want to edit this record(y/n):"); fflush(file); if(toupper(getche())=='Y'){ //textcolor(0); gotoxy(25,34); printf("1- edit name "); gotoxy(25,35); printf("2- edit code "); gotoxy(25,36); printf("3- edit rate "); gotoxy(25,37); printf("4- edit quantity "); gotoxy(25,39); ; printf(" enter your choice(1, 2, 3, 4) "); scanf("%d",&choice); switch(choice){ case 1: system("cls"); window(23,48,20,40); gotoxy(35,18);printf("EDIT RECORDS"); gotoxy(25,24); printf(" enter new name: "); scanf("%s",item.name); size=sizeof(item); fseek(file,-size,SEEK_CUR);fwrite(&item,sizeof(item),1,file); break; case 2: system("cls"); window(23,65,20,40); gotoxy(35,18);printf("EDIT RECORDS"); gotoxy(25,24); c_code(y); strcpy(item.code,y); size=sizeof(item); fseek(file,-size,SEEK_CUR);fwrite(&item,sizeof(item),1,file); break; case 3: system("cls"); window(23,65,20,40); gotoxy(35,18);printf("EDIT RECORDS"); gotoxy(25,24); printf(" enter new rate: "); scanf("%f",&item.rate); size=sizeof(item); fseek(file,-size,SEEK_CUR);fwrite(&item,sizeof(item),1,file); break; case 4: system("cls"); window(23,65,20,40); gotoxy(35,18);printf("EDIT RECORDS"); gotoxy(25,24); printf(" enter new quantity: "); scanf("%d",&item.quantity); size=sizeof(item); fseek(file,-size,1);fwrite(&item,sizeof(item),1,file); break; } gotoxy(27,30);printf("--- item edited---"); break; } } } } if (flag==1){ gotoxy(32,30);printf("item does not exist"); gotoxy(36,32);printf("TRY ABGAIN"); } getch(); fclose(file); d_mainmenu(); } /*function to display all records*/ void d_all() { int i,j=1; FILE *file; dis_con(); file=fopen("record.txt","rb"); rewind(file); i=26; fflush(file); while(fread(&item,sizeof(item),1,file)){ display(&item,i,j); i++; j++; if ((j%20)==0){ gotoxy(27,47);/*textcolor(0)*/;printf("press any key to see more..........."); getch(); system("cls"); dis_con(); i=26; continue; } } getch(); if (i==26) { gotoxy(24,30); printf("-- no articles found --"); } getch(); fclose(file); d_mainmenu(); } /*function to display by quantity*/ void d_quan() { int i,j=1; int a,b; FILE *file; dis_con(); file=fopen("record.txt","rb"); rewind(file); i=26; gotoxy(16,20);;printf("enter lower range: "); scanf("%d",&a); gotoxy(16,21);printf("enter upper range:"); scanf("%d",&b); fflush(file); while(fread(&item,sizeof(item),1,file)){ if((item.quantity>=a)&&(item.quantity<=b)){ display(&item,i,j); i++; j++; if ((j%20)==0){ gotoxy(27,47);printf("press any key to see more..........."); getch(); system("cls"); dis_con(); i=26; continue; } } } getch(); if (i==26){ gotoxy(28,30); printf(" no item found "); } getch(); d_search(); fclose(file); } /*function to display by rate*/ void d_rate(){ int i,j=1; float a,b; FILE *file; dis_con(); file=fopen("record.txt","rb"); rewind(file); i=26; gotoxy(16,20);;printf("enter lower range: "); scanf("%f",&a); gotoxy(16,21);printf("enter upper range: "); scanf("%f",&b); fflush(file); while(fread(&item,sizeof(item),1,file)){ if((item.rate>=a)&&(item.rate<=b)){ display(&item,i,j); i++; j++; if ((j%20)==0){ gotoxy(27,47);printf("press any key to see more..........."); getch(); system("cls"); dis_con(); i=26; continue; } } } getch(); if (i==26){ gotoxy(28,30); printf(" no item found "); } getch(); fclose(file); d_search(); } /*function to display by code*/ void d_code() { int i,j=1; char x[4]={0}; FILE *file; dis_con(); file=fopen("record.txt","rb"); rewind(file); i=26; gotoxy(16,20);;printf("enter item code: "); scanf("%s",x); fflush(file); while(fread(&item,sizeof(item),1,file)){ if((strcmp(item.code,x)==0)){ display(&item,i,j); i++; j++; break; } } if (i==26){ gotoxy(28,30); printf("no item found"); } getch(); fclose(file); d_search(); } /*function to display window for item display*/ void dis_con() { int i; system("cls"); gotoxy(20,10); ; for (i=1;i<=10;i++) printf("*"); printf(" * FASHION WEAR * "); for (i=1;i<=10;i++) printf("*"); printf("\n\n"); gotoxy(30,11);printf("Departmental Store"); //textcolor(1); gotoxy(32,17);printf("RECORDS") ; //textcolor(8); gotoxy(18,23);printf ("SN Item Name Item Code Rate Quantity"); } /*function to display in screen*/ void display(rec *item,int i,int j) { gotoxy(16,i);//textcolor(13); printf("%4d",j); printf("%9s",item->name); printf("%12s",item->code); printf("%14.2f",item->rate); printf("%11d",item->quantity); } /*function to delete records*/ void del() { int flag; char x[ANS]; FILE *file,*file1; system("cls"); //textbackground(11); //textcolor(0); window(23,51,25,34); gotoxy(29,18);printf("DELETE ARTICLES"); gotoxy(27,27);printf("enter item code: "); scanf("%s",x); flag=check(x); if(flag==0){ file1=fopen("record1.txt","ab"); file=fopen("record.txt","rb"); rewind(file); while (fread(&item,sizeof (item),1,file)){ if(strcmp(item.code,x)!=0) fwrite(&item,sizeof(item),1,file1); } gotoxy(27,29);printf("---item deleted---"); remove("record.txt"); rename("record1.txt","record.txt"); } if (flag==1){ gotoxy(25,29);printf("---item does not exist---"); gotoxy(30,31);printf("TRY AGAIN"); } fclose(file1); fclose(file); getch(); d_mainmenu(); } /*function to check validity of code while editing and deleting*/ int check(char x[ANS]) { FILE *file; int flag=1; file=fopen("record.txt","rb"); rewind(file); while (fread(&item,sizeof (item),1,file)){ if(strcmp(item.code,x)==0){ flag=0; break; } } fclose(file); return flag; } /*function to display box*/ void window(int a,int b,int c,int d) { int i; system("cls"); gotoxy(20,10); //textcolor(1); for (i=1;i<=10;i++) printf("*"); printf(" * FASHION WEAR * "); for (i=1;i<=10;i++) printf("*"); printf("\n\n"); gotoxy(30,11);printf("Departmental Store"); //textcolor(4); for (i=a;i<=b;i++){ gotoxy(i,17);printf("\xcd"); gotoxy(i,19);printf("\xcd"); gotoxy(i,c);printf("\xcd"); gotoxy(i,d);printf("\xcd"); } gotoxy(a,17);printf("\xc9"); gotoxy(a,18);printf("\xba"); gotoxy(a,19);printf("\xc8"); gotoxy(b,17);printf("\xbb"); gotoxy(b,18);printf("\xba"); gotoxy(b,19);printf("\xbc"); //textcolor(4); for(i=c;i<=d;i++){ gotoxy(a,i);printf("\xba"); gotoxy(b,i);printf("\xba"); } gotoxy(a,c);printf("\xc9"); gotoxy(a,d);printf("\xc8"); gotoxy(b,c);printf("\xbb"); gotoxy(b,d);printf("\xbc"); //textbackground(11); //textcolor(0); } |
You can download the source code here.

Related Article
destination source:https://www.programming-techniques.com/?p=2362