DSA Mini - Project
DSA Mini - Project
Aim: The aim of this billing system implemented in C is to create a comprehensive program that
enables users to generate invoices for a variety of products, categorizing them into cosmetics,
groceries, and beverages. The system captures customer details, item details, and computes the total
amount with consideration of GST rates. The primary goal is to demonstrate a functional and efficient
billing system utilizing C language and integrating Data Structures and Algorithms (DSA) concepts.
Programming Language: C
Theory:
Algorithm
Define a structure 'Product' to encapsulate product details, including name, price, quantity,
and GST rate.
Take user input for the quantity of each product.
Calculate and print details for each product, including quantity, GST rate, GST amount, and
total amount. Update the overall total.
Display category-wise headers for cosmetics, groceries, and beverages, as well as the final
invoice header.
Initialize an array of Product structures with predefined product details.
Capture customer details such as name, phone number, and customer ID.
Iterate through the product array, taking quantity inputs, and calculate totals for each category
(cosmetics, groceries, beverages).
Print the final invoice, including details of all products and the overall total.
Structures: Utilize the 'struct' keyword to create a composite data type (Product) to represent
each product's attributes.
Arrays: Employ arrays to store multiple Product structures for different products.
Iteration: Employ 'for' loops for iterating through product categories and individual products.
Input/Output Operations: Utilize standard input/output functions like 'printf' and 'scanf' for
user interaction.
Time Complexity: The time complexity of this billing system is O(n), where 'n' is the number
of products. The program iterates through each product once to input quantities, calculate
totals for each category, and print the final invoice.
Space Complexity: The space complexity is O (1), as the amount of additional memory
required is constant and does not scale with the input size. The primary memory usage is for
the array of Product structures and a few variables.
Code:
#include <stdio.h>
scanf("%d", &product->quantity);
void printCategoryHeader(const char
} *category) {
Department of Electronics & Telecommunication Engineering
Data Structures & Algorithms Lab (DJ19ECSBL1)
printf("|----------------------|------------|---------
-|------------|-----------|\n"); int cosmeticsTotal = 0, groceriesTotal = 0,
beveragesTotal = 0;
}
printf("|----------------------|------------|---------
-|------------|-----------|\n"); printf("Customer Name : ");
printf("| Product Name | Quantity | char name[50];
GST Rate | GST Amount | Total |\n");
scanf("%s", name);
printf("|----------------------|------------|---------
-|------------|-----------|\n"); printf("Customer Number : ");
} int phone_number;
scanf("%d", &phone_number);
printf("Customer Id : ");
scanf("%d", &customer_id);
printf("--------------------------------------------
----------------------------\n"); printCategoryHeader("Beverages");
printf("-------------------------------------------- printProduct(&products[i],
----------------------------\n"); &beveragesTotal);
printf("--------------------------------------------
----------------------------\n");
}
Department of Electronics & Telecommunication Engineering
Data Structures & Algorithms Lab (DJ19ECSBL1)
return 0;
Conclusion: