0% found this document useful (0 votes)
3 views

Exercise 7 Structures

The document outlines an experiment focused on creating a billing system using C programming with structures. It details the aim, algorithm, and functions required to manage customer records, including adding, viewing, modifying, and deleting records. Additionally, it includes a learning outcome section and an exercise related to complex numbers.

Uploaded by

kartheesan.k2022
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Exercise 7 Structures

The document outlines an experiment focused on creating a billing system using C programming with structures. It details the aim, algorithm, and functions required to manage customer records, including adding, viewing, modifying, and deleting records. Additionally, it includes a learning outcome section and an exercise related to complex numbers.

Uploaded by

kartheesan.k2022
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Experiment - 7:

DATE:
CO2: Comprehend the derived data types, pointers and creation of functions.
A. Aim :
Structure : Write a program to design a billing system using structure such that it does the
following task
1. Add New Record: Add new customer record.
2. View List of Records: View all the records at a glance.
3. Modify Record: Modification of an already existing record.
4. View Payment: View the bill for a given customer.
5. Delete Record: The deletion of a record from the memory.
B. Algorithm:
1. Start
2. Data Structure to Hold Customer Information with members such as Array customers[100] of
type Customer is created to store customer records. It can hold up to 100
records.customerCount is an integer variable used to keep track of the number of customers.
3. addRecord(): Function to Add New Customer Record
• The addRecord() is created in order to add a customer record in the memory.
• It checks if the current number of customers customerCount is less than 100
ensuring there’s space for a new record.
• The function prompts the user to enter the customer’s name, phone number,
usage in minutes.
• It calculates the total bill for the customer by multiplying their usage in
minutes by 0.1.
• After adding the record, customerCount is incremented by 1.
4. viewRecords(): Function to Display Customer Records
• The function named viewRecords() is responsible for displaying the list of
customer records.
• It uses a loop to iterate through each customer record.
• Within the loop, it prints the name, phone number, usage in minutes, and
total bill for each customer.
5. modifyRecord(): Modifying Customer Records by Phone Number
• The function modifyRecord() is responsible for modifying a customer record
using their phone number.
• It takes a character array phoneNumber as a parameter which is used to
identify the customer record to be modified.
• Using a loop, it checks if the phone number of the current customer
matches the provided phoneNumber.
• If a matching phone number is found it prompts the user to enter the new
usage in minutes for the customer and the new bill is calculated based on
the updated usage.
• It displays output to the user either confirming a successful record
modification or informing them if the record was not found.
6. viewPayments(): Viewing Payment for a Customer by Phone Number
• The function viewPayment() is responsible for displaying the total bill for a
customer based on their phone number.
• It takes a char array phoneNumber as a parameter which is used to identify
the customer.
• If a matching phone number is found it prints the total bill for the customer
along with their name.

1|Page Win 24-25: course handled by M.A Inayathullaah


• It displays output to the user, either displaying the total bill or informing
them if the record was not found.
7. searchRecord(): Searching for a Customer Record by Phone Number
• This function searchRecord responsible for searching for a customer record
based on their phone number.
• It takes a char array phoneNumber as a parameter which is used to identify
the customer.
• It uses a loop to iterate through each customer record.
• Within the loop it checks if the phone number of the current customer
matches the provided phoneNumber.
• If a matching phone number is found it prints the information of the
customer including name, phone number, usage in minutes, total bill.
• It displays output to the user either displaying the customer record or
informing them if the record was not found.

8. deleteRecord(): Deleting a Customer Record by Phone Number


• This function deleteRecord() is responsible for deleting a customer record
based on their phone number.
• It takes a char array phoneNumber as a parameter which is used to identify
the customer record to be deleted.
• If a matching phone number is found, it shifts all records after the matched
record by one position to effectively delete the record.
• After deleting the record it decrements the customerCount by 1.
• It provides feedback to the user confirming a successful record deletion or
informing them the record was not found.
9. Main Function
▪ The main function handles the primary control of the program.
▪ An infinite while loop is used to provide the user with a dashboard that
resets after each.
▪ A switch case is used to process the user’s choices.

10. Stop

C. C language Program

2|Page Win 24-25: course handled by M.A Inayathullaah


3|Page Win 24-25: course handled by M.A Inayathullaah
4|Page Win 24-25: course handled by M.A Inayathullaah
D. Output window

5|Page Win 24-25: course handled by M.A Inayathullaah


6|Page Win 24-25: course handled by M.A Inayathullaah
E. Learning Outcome:

F. Exercise-7:

7.1 Create a structure named Complex to represent a complex number with real and
imaginary parts. Write a C program to add and multiply two complex numbers.

Pre Lab Marks (2-mark Max) In Lab Marks (3-mark Max) Post Lab Marks (5-mark Max)

7|Page Win 24-25: course handled by M.A Inayathullaah

You might also like