write a program of billing system in c language with explanation in hindi , C Project : Billing System ( In hindi ) :-
C Project : Billing System एक बहुत ही आसान प्रोजेक्ट है जिसे student अपने minor प्रोजेक्ट मे आसानी से सबमिट कर सकते है | इस article मे , students के support के लिए C Project : Billing System (for telecom industry ) को discuss किया गया है |
Explanation
इस प्रोजेक्ट मे मुख्य सात user define function है | जो की निन्म है :-
void main(); – इस function का use यूजर द्वारा दिए गये input के आधार पर कार्यो को perform करवाना  होता है | दूसरी भाषा मे , इस प्रोजेक्ट का हार्ट होता है |
void add(); – इस function का use , client की detail को add करने के लिए किया जाता है |
void view_record(); इस function का use , clients की लिस्ट को देखने के लिए किया जाता है |
void modify_records();- इस function का use , client की information को modify करने के लिए किया जाता है |
void delete_records();इस function का use , किसी record को डिलीट करने के लिए किया जाता है |
void search_records();इस function का use , किसी record को search करने के लिए किया जाता है |
void pay();इस function का use , किसी record के द्वारा किये गये payment को update करने के लिए किया जाता है |
main() मे ,
सबसे पहले यूजर के द्वारा choice को input करा दिया जाता है | इस choice के आधार function को call किया जाता है |
अगर user द्वारा दिए गये input ‘A’ , add() function call होगा |
अगर user द्वारा दिए गये input ‘L’ , view_record() function call होगा |
अगर user द्वारा दिए गये input ‘M’ , modify_records() function call होगा |
अगर user द्वारा दिए गये input ‘P’ , pay() function call होगा |
अगर user द्वारा दिए गये input ‘S’ , search_records() function call होगा |
अगर user द्वारा दिए गये input ‘D’ , delete_records() function call होगा |
अगर user द्वारा दिए गये input ‘E’ , Exit function call होगा |
यूजर द्वारा input की गयी choice को switch () मे pass करते है इसके आधार function call किया जाता है |
void add() मे ,
file जिसमे data को add करना है का नाम data.ojs है |
1.सबसे पहले file को append mode मे open करते है |
2.फिर loop चलाया जाता है जो continuos चलता है क्योकि exits का option loop की body मे है |
loop की body मे ,
3.यूजर के द्वारा client का नाम को structure client के customer_name member मे assign हो जाता है
4.यूजर के द्वारा  client का phone number  को structure client के phone member मे assign हो जाता है |
5.यूजर के द्वारा  client के द्वारा pay की जाने वाले अमाउंट को   को structure client के BillAmount member मे assign हो जाता है |
6.इस तरह से client की detail insert हो जाती है | अगर यूजर द्वारा escape press किया जाता है तब loop terminate हो जाता है |
7.अन्यथा दुरसे client की detail को add किया जाता है |
view_record() मे ,
 file जिसमे data को add करना है का नाम data.ojs है |
1.सबसे पहले file को read  mode मे open करते है |
2.फिर loop चलाया जाता है जो तब तक  चलता है जब तक की ‘i’ की value ,file मे store होने वाली record से कम होती है |
उसके बाद while loop चलाया जाता है जिसमे सभी structure की detail को print किया जाता है |
3.यूजर के द्वारा client का नाम को print किया जाता है
4.यूजर के द्वारा  client का phone number  print किया जाता है |
5.यूजर के द्वारा  client के द्वारा pay की जाने वाले अमाउंट को  किया  जाता है |
6.इस तरह , file मे उपस्थित सभी record की detail print हो जाती है |
void modify_records() मे 
1.सबसे पहले जिस record को modify करना है उसका phone number input करा लेते है इसे change_phone मे assign करा लेते है |
2.loop चलाया जाता है |
3.अगर file मे कोई record का phone number , यूजर द्वारा input किये गये phone number से सामान होता है तब
4.उस position पर यूजर द्वारा किये गये नया इनपुट्स को add करा लेते है |
 
void search_records()
1.सबसे पहले जिस record को modify करना है उसका phone number input करा लेते है इसे search_phone मे assign करा लेते है |
2.loop चलाया जाता है |
3.अगर file मे कोई record का phone number , यूजर द्वारा input किये गये phone number से सामान होता है तब
4.उस position पर उपस्थित record को display करते है |
void pay() मे ,
1.सबसे पहले जिस record को modify करना है उसका phone number input करा लेते है इसे search_phone मे assign करा लेते है |
2.loop चलाया जाता है |
3.अगर file मे कोई record का phone number , यूजर द्वारा input किये गये phone number से सामान होता है तब
4.उस position पर उपस्थित record के लिए paid amount को calculate करते है |
 
Source Code
 
#include<stdio.h>
 
#include<conio.h>
#include<ctype.h>
#include<windows.h>
#include<stdlib.h>
struct customer
{
char phone[20];
char customer_name[50];
float BillAmount;
}s;
void add();
void view_record();
void modify_records();
void delete_records();
void search_records();
void pay();
char get;
int main()
{ int pass;
 int phone;
 char c;
 system(“cls”);
 printf(“\n\n\n\n\n\n\n\n\n**************************************************************”);
 printf(“\n\t\t——WELCOME TO THE BILLING MANAGEMENT SYSTEM ( For Telecom Sector )—“);
 printf(“\n\t\t****************************************************************”);
 Sleep(3000);
 getch();
    system(“cls”);
 while (1)
 {
 system(“cls”);
 printf(“\n A : for adding new records.\n “);
 printf(“\n L : for viewing list of records\n”)
 printf(“\n M : for modifying records.\n”);
 printf(“\n P : for payment.\n”);
 printf(“\n S : for searching records.\n”);
 printf(“\n D : for deleting records.\n “);
 printf(“\n E : for exit\n”);
 c=getche();
 c=toupper(c);
 switch(c)
 {
 case ‘P’:
 pay();
 break;
 case ‘A’:
 add();
 break;
 case ‘L’:
 view_record();
 break;
 case ‘M’:
 modify_records();
 break;
 case ‘S’:
 search_records();
 break;
 case ‘D’:
 delete_records();
 break;
 case ‘E’:
 system(“cls”);
 printf(“\n\n\t\t\t\tTHANK YOU”);
 printf(“\n\n\n\n\n:\n\t Using this portal for your data maintance”);
 Sleep(3000);
 exit(0);
 break;
 default:
 system(“cls”);
 printf(“Incorrect Choice”);
 printf(“\n Press Any key to continue”);
 getch();
 }
 }
}
void add()
{
 FILE *f;
 char test;
 f=fopen(“c:/data.ojs”,”ab+”); // here file data.ojs : file name .which contain datas //
 if(f==0)
 {   f=fopen(“c:/data.ojs”,”wb+”);
 system(“cls”);
 printf(“please wait while we ready your system”);
 printf(“/n Press any key to continue”);
 getch();
 }
 while(1)
 {
 system(“cls”);
 printf(“\n phone number: “);
 scanf(“%s”,&s.phone);
 printf(“\n Enter customer Name:”);
 fflush(stdin);
 scanf(“%[^\n]”,&s.customer_name);
 printf(“\n Enter Bill Amount:”);
 scanf(“%f”,&s.BillAmount);
 fwrite(&s,sizeof(s),1,f);
 fflush(stdin);
 system(“cls”);
 printf(” Your record successfully added”);
 printf(“\n Press esc key to exit, any other key to add other record:”);
 test=getche();
 if(test==27)  // 27 is ASCII value of ESC key // 
 break;
 }
 fclose(f);  //file close //
}
void view_record()
{
 FILE *f;
 int i;
 if((f=fopen(“c:/data.ojs”,”rb”))==NULL)
 exit(0);
 system(“cls”);
 printf(“Phone Number\t\tUser customer Name\t\t\t Bill Amount\n”);
 for(i=0;i<80;i++) // Here 80 is limit of record //
 printf(“-“);
 while(fread(&s,sizeof(s),1,f)==1)
 {
 printf(“\n%-10s\t\t%-20s\t\tRs. %.2f /-“,s.phone,s.customer_name,s.BillAmount);
 }
 printf(“\n”);
 for(i=0;i<80;i++)
 printf(“-“);
fclose(f);
getch();
}
void delete_records()
{
 FILE *f,*t;
 int i=1;
 char del_phone[20];
 if((t=fopen(“c:/temp.ojs”,”w+”))==NULL)
 exit(0);
 if((f=fopen(“c:/data.ojs”,”rb”))==NULL)
 exit(0);
 system(“cls”);
 printf(“Enter the phone number to be deleted from the Database”);
 fflush(stdin);
 scanf(“%[^\n]”,del_phone);
 while(fread(&s,sizeof(s),1,f)==1)
 {
 if(strcmp(s.phone,del_phone)==0)
 {       i=0;
 continue;
 }
 else
 fwrite(&s,sizeof(s),1,t);
 }
 if(i==1)
 {       system(“cls”);
 printf(“Phone number \”%s\” not found in database “,del_phone);
 remove(“c:/data.ojs”);
 rename(“c:/temp.ojs”,”c:/data.ojs”);
 getch();
 fclose(f);
 fclose(t);
 main();
 }
 remove(“c:/data.ojs”);
 rename(“c:/temp.ojs”,”c:/data.ojs”);
 system(“cls”);
 printf(“The Number %s Successfully Deleted!!!!”,del_phone);
 fclose(f);    // close main file //
 fclose(t);   // close temperory File //
 getch();
}
void search_records()
{
 FILE *f;
 char search_phone[20];
 int flag=1;
 f=fopen(“c:/data.ojs”,”rb+”);
 if(f==0)
 exit(0);
 fflush(stdin);
 system(“cls”);
 printf(“Enter Phone Number to search in our database”);
 scanf(“%s”, search_phone);
 while(fread(&s,sizeof(s),1,f)==1)
 {
 if(strcmp(s.phone,search_phone)==0)
 { system(“cls”);
 printf(” Record Founded ! Details is given below. “);
 printf(“\n\nphone: %s\ncustomer_name: %s\nBillAmount: Rs.%0.2f\n”,s.phone,s.customer_name,s.BillAmount);
 flag=0;
 break;
 }
 else if(flag==1)
 { system(“cls”);
 printf(“Phone Number %s Not found in database “,search_phone);
 }
 }
 getch();
 fclose(f);
}
void modify_records()
{
 FILE *f;
 char change_phone[20];
 long int size=sizeof(s);
 if((f=fopen(“c:/data.ojs”,”rb+”))==NULL)
 exit(0);
 system(“cls”);
 printf(“Enter phone number of the customer to modify:”);
 scanf(“%[^\n]”,change_phone);
 fflush(stdin);
 while(fread(&s,sizeof(s),1,f)==1)
 {
 if(strcmp(s.phone,chnage_phone)==0)
 {
 system(“cls”);
 printf(“\n Enter phone number:”);
 scanf(“%s”,&s.phone);
 printf(“\n Enter customer name: “);
 fflush(stdin);
 scanf(“%[^\n]”,&s.customer_name);
 printf(“\n Enter Bill Amount: “);
 scanf(“%f”,&s.BillAmount);
 fseek(f,-size,SEEK_CUR);
 fwrite(&s,sizeof(s),1,f);
 break;
 }
 }
 fclose(f);
}
void pay()
{
 FILE *f;
 char pay_phone[20];
 long int size=sizeof(s);
 float PaidAmount;
 int i;
 if((f=fopen(“c:/data.ojs”,”rb+”))==NULL)
 exit(0);
 system(“cls”);
 printf(“Enter phone number of the customer for pay”);
 scanf(“%[^\n]”,pay_phone);
 fflush(stdin);
 while(fread(&s,sizeof(s),1,f)==1)
 {
 if(strcmp(s.phone,pay_phone)==0)
 {
 system(“cls”);
 printf(“\n Phone No.: %s”,s.phone);
 printf(“\n customer_name: %s”,s.customer_name);
 printf(“\n Current BillAmount: %f”,s.BillAmount);
 printf(“\n”);
 for(i=0;i<79;i++)
 printf(“-“);
 printf(“\n\nEnter Bill Amount of pay :”);
 fflush(stdin);
 scanf(” %f”,&PaidAmount);
 s.BillAmount=s.BillAmount-PaidAmount;
 fseek(f,-size,SEEK_CUR);
 fwrite(&s,sizeof(s),1,f);
 break;
 }
 }
 system(“cls”);
 printf(“THANK YOU %s ! FOR Paying Your Bill On Time “,s.customer_name);
 getch();
 fclose(f);
}