0% found this document useful (0 votes)
32 views24 pages

Telecom Billing Management System Code

This C program code implements a telecom billing management system with the following key features: 1. It allows users to add, view, modify, search, delete subscriber records and make payments. 2. Subscriber records contain phone number, name, and amount fields stored in a struct. 3. A menu is displayed to users to select operations and navigate between adding, viewing, searching etc of subscriber records stored in a text file.

Uploaded by

Mr. Perfect
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views24 pages

Telecom Billing Management System Code

This C program code implements a telecom billing management system with the following key features: 1. It allows users to add, view, modify, search, delete subscriber records and make payments. 2. Subscriber records contain phone number, name, and amount fields stored in a struct. 3. A menu is displayed to users to select operations and navigate between adding, viewing, searching etc of subscriber records stored in a text file.

Uploaded by

Mr. Perfect
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Source code

#include<stdio.h>
#include<conio.h>
#include<windows.h>
#include<stdlib.h>
struct subscriber
{
char phonenumber[20];
char name[50];
float amount;
}s;
void gotoxy(int,int);
void addrecords();
void listrecords();
void modifyrecords();
void deleterecords();
void searchrecords();
void payment();
void login();

5
char get;
int main()
{ int password;
int phonenumber;
char choice;

system("cls");
system("color 0");
gotoxy(10,2);
system("cls");
system("color 0F");
gotoxy(0,2);

printf("\t\t**********************************************
******************");
printf("\n\t\t ------WELCOME TO THE TELECOM BILLING
MANAGEMENT SYSTEM------");

printf("\n\t\t********************************************
********************");
printf("\n\n\n\t\t Press Any Key To Continue. . ");
Sleep(0);

6
getch();
system("cls");
login();
system ("color 0F");

system("cls");
system ("color 0F");
gotoxy(30,0);
system("color 0F");
printf("\n\n\xDB\xDB\xDB\xDB\xDB TELECOM BILLING
SYSTEM \xDB\xDB\xDB\xDB\xDB");

while (1){
printf(" \n\n \xDB\xDB 1 : Add New Records.\n\n
\xDB\xDB 2 : List Of Records");
printf("\n\n \xDB\xDB 3 : Modify Records.\n\n \xDB\xDB 4 :
For Payment");
printf("\n\n \xDB\xDB 5 : Search Records.");
printf("\n\n \xDB\xDB 6 : Delete Records.\n\n \xDB\xDB
7 : Exit\n");

7
printf("\n Enter Your Choice:-");
choice=getche();
choice=toupper(choice);
switch(choice)
{
case '1':
addrecords();break;
case '2':
listrecords();break;
case '3':
modifyrecords();break;
case '4':
payment() ;break;
case '5':
searchrecords() ;break;
case '6':
deleterecords();break;
case '7':
system("cls");
system("color 0F");

8
gotoxy(1,25);
printf("\xDB\xDB\xDB\xDB\xDB\xDB\xDB");
gotoxy(1,26);
printf(" \xDB");
gotoxy(1,27);
printf(" \xDB");
gotoxy(1,28);
printf(" \xDB");
gotoxy(1,29);
printf(" \xDB");
gotoxy(1,30);
printf(" \xDB");
gotoxy(1,31);
printf(" \xDB");
gotoxy(10,25);
printf("\xDB \xDB");
gotoxy(10,26);
printf("\xDB \xDB");
gotoxy(10,27);
printf("\xDB \xDB");

9
gotoxy(10,28);
printf("\xDB\xDB\xDB\xDB\xDB\xDB\xDB");
gotoxy(10,29);
printf("\xDB \xDB");
gotoxy(10,30);
printf("\xDB \xDB");
gotoxy(10,31);
printf("\xDB \xDB");
gotoxy(19,25);
printf("\xDB\xDB\xDB\xDB\xDB\xDB\xDB");
gotoxy(19,26);
printf("\xDB \xDB");
gotoxy(19,27);
printf("\xDB \xDB");
gotoxy(19,28);
printf("\xDB\xDB\xDB\xDB\xDB\xDB\xDB");
gotoxy(19,29);
printf("\xDB \xDB");
gotoxy(19,30);
printf("\xDB \xDB");

10
gotoxy(19,31);
printf("\xDB \xDB");
gotoxy(28,25);
printf(" \xDB");
gotoxy(28,26);
printf("\xDB\xDB \xDB");
gotoxy(28,27);
printf("\xDB \xDB \xDB");
gotoxy(28,28);
printf("\xDB \xDB \xDB");
gotoxy(28,29);
printf("\xDB \xDB \xDB");
gotoxy(28,30);
printf("\xDB \xDB\xDB");
gotoxy(28,31);
printf("\xDB");
gotoxy(37,25);
printf("\xDB \xDB");
gotoxy(37,26);
printf("\xDB \xDB");

11
gotoxy(37,27);
printf("\xDB \xDB");
gotoxy(37,28);
printf("\xDB\xDB\xDB\xDB");
gotoxy(37,29);
printf("\xDB \xDB");
gotoxy(37,30);
printf("\xDB \xDB");
gotoxy(37,31);
printf("\xDB \xDB");
gotoxy(46,25);
printf("\xDB \xDB");
gotoxy(46,26);
printf(" \xDB \xDB");
gotoxy(46,27);
printf(" \xDB \xDB");
gotoxy(46,28);
printf(" \xDB");
gotoxy(46,29);
printf(" \xDB");

12
gotoxy(46,30);
printf(" \xDB");
gotoxy(46,31);
printf(" \xDB");
gotoxy(55,25);
printf("\xDB\xDB\xDB\xDB\xDB\xDB\xDB");
gotoxy(55,26);
printf("\xDB \xDB");
gotoxy(55,27);
printf("\xDB \xDB");
gotoxy(55,28);
printf("\xDB \xDB");
gotoxy(55,29);
printf("\xDB \xDB");
gotoxy(55,30);
printf("\xDB \xDB");
gotoxy(55,31);
printf("\xDB\xDB\xDB\xDB\xDB\xDB\xDB");
gotoxy(64,25);
printf("\xDB \xDB");

13
gotoxy(64,26);
printf("\xDB \xDB");
gotoxy(64,27);
printf("\xDB \xDB");
gotoxy(64,28);
printf("\xDB \xDB");
gotoxy(64,29);
printf("\xDB \xDB");
gotoxy(64,30);
printf("\xDB \xDB");
gotoxy(64,31);
printf("\xDB\xDB\xDB\xDB\xDB\xDB\xDB");
Sleep(2000);
exit(0);
break;
default:
system("cls");
system("color 0F");
gotoxy(30,20);
printf("Incorrect Input");

14
printf("\a......");
gotoxy(30,24);
printf("Any key to continue");
getch();
}
}
}
COORD coord = {0, 0};
// sets coordinates to 0,0
//COORD max_buffer_size = GetLargestConsoleWindowSize(hOut);
COORD max_res,cursor_size;
void gotoxy (int x,int y)
{

coord.X = x; coord.Y = y;
// X and Y coordinates

SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),
coord);
}

15
void addrecords()
{
FILE *f;
char test;
f=fopen("[Link]","ab+");
if(f==0)
{ f=fopen("[Link]","wb+");
system("cls");
printf("Please wait while we configure your computer");
printf("\npress any key to continue");
getch();
}
while(1)
{
system("cls");
printf("\n Enter phone number: ");
scanf("%s",&[Link]);
printf("\n Enter name: ");
fflush(stdin);
scanf("%s",&[Link]);

16
printf("\n Enter amount: ");
scanf("%f",&[Link]);
fwrite(&s,sizeof(s),1,f);
fflush(stdin);
printf("\n\n Record Is Successfully Added");
printf("\n Press esc Key to exit or Press any other key to
add other record:");
test=getche();
if(test==27)
break;
}
fclose(f);
system("cls");
}
void listrecords()
{
FILE *f;
int i;
if((f=fopen("[Link]","rb"))==NULL)
exit(0);

17
system("cls");
printf("Phone Number\t\tUser Name\tAmount\n");
for(i=0;i<79;i++)
printf("-");
while(fread(&s,sizeof(s),1,f)==1)
{
printf("\n%s\t\t%s\t\tRs.
%.2f /-",[Link],[Link],[Link]);
}
printf("\n");
for(i=0;i<79;i++)
printf("-");

fclose(f);
printf("\n\nPress Any Key To Go Back");
getch();
system("cls");
}
void deleterecords()
{

18
FILE *f,*t;
char phonenumber[20];
system("cls");
f=fopen("[Link]","rb+");
t=fopen("[Link]","wb+");
do{
rewind(f);
printf("Enter the phone number to be deleted from the
Database: ");
scanf("%s",phonenumber);
while(fread(&s,sizeof(s),1,f)==1)
{
if(strcmp([Link],phonenumber)!=0)
{ fwrite(&s,sizeof(s),1,t);

}
else
printf("Record deleted successfully.");
}

19
fclose(f);
fclose(t);
remove("[Link]");
rename("[Link]","[Link]");

f=fopen("[Link]","rb+");
t=fopen("[Link]","wb+");
printf("\nDo you want to delete another record (y/n):");
fflush(stdin);
}
while(getche()=='y'||getche()=='Y');
fclose(f);
getch();
system("cls");
}
void searchrecords()
{
FILE *f;
char phonenumber[20];
int flag=1;

20
f=fopen("[Link]","rb+");

fflush(stdin);
system("cls");
printf("Enter Phone Number to search in our database: ");
scanf("%s", phonenumber);
while(fread(&s,sizeof(s),1,f)==1)
{
if(strcmp([Link],phonenumber)==0)
{ system("cls");
printf(" Record Found ");
printf("\n\nPhonenumber: %s\nName:
%s\nAmount: Rs.%0.2f\n",[Link],[Link],[Link]);
flag=0;
break;
}
else if(flag==1)
{ system("cls");
printf("Requested Phone Number Not found in our
database");

21
}
}
getch();
fclose(f);
system("cls");
}
void modifyrecords()
{
FILE *f;
char phonenumber[20];
long int size=sizeof(s);
if((f=fopen("[Link]","rb+"))==NULL)
exit(0);
system("cls");
printf("Enter phone number of the subscriber to modify: ");
scanf("%s",phonenumber);
fflush(stdin);
while(fread(&s,sizeof(s),1,f)==1)
{
if(strcmp([Link],phonenumber)==0)

22
{
system("cls");
printf("\n Enter phone number: ");
scanf("%s",&[Link]);
printf("\n Enter name: ");
fflush(stdin);
scanf("%[^\n]",&[Link]);
printf("\n Enter amount: ");
scanf("%f",&[Link]);
fseek(f,-size,SEEK_CUR);
fwrite(&s,sizeof(s),1,f);
break;
}
}
fclose(f);
system("cls");
}
void payment()
{
FILE *f;

23
char phonenumber[20];
long int size=sizeof(s);
float amt;
int i;
if((f=fopen("[Link]","rb+"))==NULL)
exit(0);
system("cls");
printf("Enter phone number of the subscriber for payment: ");
scanf("%s",phonenumber);
fflush(stdin);
while(fread(&s,sizeof(s),1,f)==1)
{
if(strcmp([Link],phonenumber)==0)
{
printf("\n ***DETAILS***");
printf("\n Phone No.: %s",[Link]);
printf("\n Name: %s",[Link]);
printf("\n Current amount: %f",[Link]);
printf("\n");
for(i=0;i<79;i++)

24
printf("-");
printf("\n\nEnter amount of payment: ");
fflush(stdin);
scanf(" %f",&amt);
[Link]=[Link]-amt;
fseek(f,-size,SEEK_CUR);
fwrite(&s,sizeof(s),1,f);
break;
}
}
printf("\n\n");
printf("System Message: THANK YOU %s FOR YOUR TIMELY
PAYMENTS!!",[Link]);
getch();
fclose(f);
system("cls");
}
void login()
{
int a=0,i=0;

25
char uname[10],c=' ';
char pword[10],code[10];
char user[10]="user";
char pass[10]="pass";
do
{

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++;
}

26
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 TO OUR SYSTEM !!!! LOGIN IS
SUCCESSFUL");
printf("\n\n\n\t\t\t\tPress any key to continue...");
getch();//holds the screen
break;
}
else
{
printf("\n SORRY !!!! LOGIN IS UNSUCESSFUL");
a++;

getch();//holds the screen


system("cls");

27
}
}
while(a<=2);
if (a>2)
{
printf("\nSorry you have entered the wrong username
and password for four times!!!");

getch();

}
system("cls");
}

28

Common questions

Powered by AI

The 'searchrecords' function locates a specific subscriber by opening 'pro.txt' in read mode and comparing each record's phone number against the user-provided phone number using 'strcmp'. If there's a match, it displays the subscriber's information; if not, it flags that the record isn't found. This sequential search ensures each record is checked .

Storing phone numbers as strings might cause inconsistencies if different formats or invalid characters are entered, as there is no inherent validation or standardization without additional logic. It also prevents arithmetic operations directly on phone numbers, although generally unnecessary for such data .

The program uses the 'listrecords' function to display all subscriber records. It opens 'pro.txt' in read mode, formats each record with headers 'Phone Number', 'User Name', and 'Amount', and iteratively reads and prints each subscriber's details in a tabular format. The function ensures clarity by drawing lines between records with a for-loop and closing the file after use .

The login mechanism involves checking the inputted username and password against predefined values ('user' and 'pass'). It uses a do-while loop to allow three attempts. The password input is obscured as asterisks during entry to enhance security. After successful login, a welcome message is displayed; otherwise, an error message and a retry prompt appear .

The 'gotoxy' function is used to position the console cursor at a specific location in the console window, defined by the (x, y) coordinates. It is implemented by setting the COORD structure's X and Y properties to the specified coordinates and then calling SetConsoleCursorPosition with a handle to the standard output device .

The main function handles incorrect user inputs by using a switch-case structure. If the user enters an input that doesn't match any of the predefined cases, it defaults to display a message 'Incorrect Input', alerts with a beep, and prompts the user to press any key to continue, effectively resetting the menu .

The system maintains data consistency after deletion by using two files: 'pro.txt' and 'pro1.txt'. It reads each record from 'pro.txt', writes records not matching the delete criteria to 'pro1.txt', and then deletes 'pro.txt'. Finally, 'pro1.txt' is renamed to 'pro.txt', ensuring the original file only contains the updated records .

The 'payment' function adjusts a subscriber's billing amount by prompting the user to enter the subscriber's phone number to locate the record, displaying the current amount, and then subtracting the user-inputted payment amount from the current amount. After adjustment, the record is updated in the file using fseek and fwrite functions .

New subscriber records are added using the 'addrecords' function. This function opens a file 'pro.txt' in appending mode ('ab+'). If the file doesn't exist, it creates one ('wb+'). The function then collects input for phone number, name, and amount from the user, writes the data into the file using 'fwrite', and continues to prompt the user to add more records or exit by pressing the escape key .

To identify issues in the Telecom Billing Management System, one could use debugging strategies such as inserting print statements to trace variable states and control flow, employing a debugger to inspect memory usage and function calls, setting breakpoints, and testing edge cases. Logs for file operations and input validation checks could also highlight potential errors .

You might also like