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

DSA Mini - Project

The document describes a C program for a billing system that generates invoices for products categorized into cosmetics, groceries, and beverages. It takes customer and item details as input, calculates totals and GST for each item and category, and prints the final invoice. Data structures like structs and arrays are used along with functions for modularity.

Uploaded by

darshil shah
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
69 views

DSA Mini - Project

The document describes a C program for a billing system that generates invoices for products categorized into cosmetics, groceries, and beverages. It takes customer and item details as input, calculates totals and GST for each item and category, and prints the final invoice. Data structures like structs and arrays are used along with functions for modularity.

Uploaded by

darshil shah
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Department of Electronics & Telecommunication Engineering

Data Structures & Algorithms Lab (DJ19ECSBL1)

Data Structures & Algorithms(DJ19ECSBL1) Mini Project report

Academic Year 2023-24

Sr. SAP ID Name of student


No.

1 60002210064 Pratham Mishra

2 60002210105 Awadhesh Thakur

3 60002210028 Darshil Shah

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 category-wise details and totals.

 Print the final invoice, including details of all products and the overall total.

DSA Concepts Used


Department of Electronics & Telecommunication Engineering
Data Structures & Algorithms Lab (DJ19ECSBL1)

 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.

 Functions: Use functions to encapsulate specific functionalities, promoting modularity and


readability.

 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>

void printProduct(struct Product *product, int


*total) {
struct Product {
float gstAmount = (product->price *
char name [20]; product->quantity * product->gstRate) / 100;
int price; int productTotal = (product->price *
product->quantity) + gstAmount;
int quantity;
*total += productTotal;
float gstRate; // New member to store GST
rate

}; printf("| %-20s | %-10d | %-8.2f%%| %-10d


| %-10d|\n", product->name, product-
>quantity, product->gstRate, (int)gstAmount,
void inputProduct(struct Product *product) { productTotal);

printf("%s ( RS %d ) : ", product->name, }


product->price);

scanf("%d", &product->quantity);
void printCategoryHeader(const char
} *category) {
Department of Electronics & Telecommunication Engineering
Data Structures & Algorithms Lab (DJ19ECSBL1)

printf("-------------------------------------------- {"Sugar per Kg", 40, 0, 5}, {"Tea", 15, 0,


----------------------------\n"); 5}, {"Coffee", 50, 0, 5}, {"Rice per Kg", 55, 0,
5}, {"Wheat per Kg", 60, 0, 5},
printf("\n%s\n", category);
{"Pepsi", 30, 0, 18}, {"Sprite", 35, 0, 18},
printf("|----------------------|------------|--------- {"Coke", 30, 0, 18}, {"Mojitos", 25, 0, 18},
-|------------|-----------|\n"); {"Thumbs Up", 35, 0, 18}
printf("| Product Name | Quantity | };
GST Rate | GST Amount | Total |\n");

printf("|----------------------|------------|---------
-|------------|-----------|\n"); int cosmeticsTotal = 0, groceriesTotal = 0,
beveragesTotal = 0;
}

void printFinalHeader(const char *final) {


printf("-------------------------\nBILLING
printf("-------------------------------------------- SYSTEM-[MINI PROJECT]\
----------------------------\n"); n-------------------------\nCustomer Details\n\
n");
printf("\n%s\n", final);

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 : ");

int main () { int customer_id;

scanf("%d", &customer_id);

struct Product products [] = { printf("--------\n");

{"Body Soap", 10, 0, 12}, {"Hair printf(" ITEMS:\n");


Cream", 100, 0, 12}, {"Body Spray", 150, 0,
12}, {"Hair Spray", 200, 0, 12}, printf("--------\n");
Department of Electronics & Telecommunication Engineering
Data Structures & Algorithms Lab (DJ19ECSBL1)

for (int i = 0; i < sizeof(products) / printf("--------------------------------------------


sizeof(products[0]); i++) { ----------------------------\n");

inputProduct(&products[i]); printf("Groceries Total Amount : %d RS\n",


groceriesTotal);
}

printf("--------------------------------------------
----------------------------\n"); printCategoryHeader("Beverages");

printf("---------------------------MODI for (int i = 9; i < sizeof(products) /


MARKET----------------------------------\n"); sizeof(products[0]); i++) {

printf("-------------------------------------------- printProduct(&products[i],
----------------------------\n"); &beveragesTotal);

printf("\nCustomer Name : %s\nCustomer }


Phone Number : %d\nCustomer Id : %d\n",
name, phone_number, customer_id); printf("--------------------------------------------
----------------------------\n");

printf("Beverages Total Amount : %d RS\


printCategoryHeader("Cosmetics"); n", beveragesTotal);

for (int i = 0; i < 4; i++) {

printProduct(&products[i], int total = cosmeticsTotal + groceriesTotal +


&cosmeticsTotal); beveragesTotal;

printf("--------------------------------------------
----------------------------\n");

printf("Cosmetics Total Amount : %d RS\


n", cosmeticsTotal); printFinalHeader("Final Invoice");

printCategoryHeader("Groceries"); for (int i = 0; i < sizeof(products) /


sizeof(products [0]); i++) {
for (int i = 4; i < 9; i++) {
printProduct(&products[i], &total);
printProduct(&products[i],
&groceriesTotal); }

}
Department of Electronics & Telecommunication Engineering
Data Structures & Algorithms Lab (DJ19ECSBL1)

printf("-------------------------------------------- printf("-----------------------THANK YOU!!


----------------------------\n"); VISIT AGAIN---------------------------\n");

printf("Total Price : %d RS\n", total);

return 0;

Result and Conclusion:


Department of Electronics & Telecommunication Engineering
Data Structures & Algorithms Lab (DJ19ECSBL1)

Conclusion:

 The billing system demonstrates practical application of data structures and


algorithms in a real-world context.
 Modular design enhances code readability and maintainability.
 Structs are effectively used to encapsulate product details, promoting organized data
representation.
 Arrays efficiently manage multiple product structures for different items in the
system.
 Functions enhance modularity, encapsulating specific functionalities for ease of
understanding.
 Iteration through product categories and items is implemented using 'for' loops,
showcasing algorithmic control flow.
 Input/output operations, specifically 'printf' and 'scanf', facilitate user interaction in
the program.
 Time complexity is linear (O(n)), where 'n' is the number of products, as the program
iterates through each product once.
 Space complexity is constant (O (1)), as the additional memory usage remains fixed
regardless of input size.
 The experiment highlights the relevance of DSA concepts in software development,
offering opportunities for further improvements, such as dynamic memory allocation
and advanced data structures for scalability and enhanced functionality.

You might also like