Exercise 7 Structures
Exercise 7 Structures
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.
10. Stop
C. C language Program
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)