Exp 10
Exp 10
LAB MANUAL
Experiment/Program 10
Create class STORE to keep track of Products (Product Code, Name and price). Display
menu of all products to users. Generate bills as per orde.
Objective:
To create a STORE class that keeps track of products, displays a menu of available products to
users, and generates bills based on user orders without using functions in C programming.
Materials Required:
A computer with a C compiler installed.
Basic knowledge of C programming, including arrays, loops, and structures.
Theory:
In C programming, classes are not explicitly supported as in object-oriented languages like C++
or Java. However, similar behavior can be simulated using structures. The STORE class can be
represented using a structure, and its operations can be carried out using loops and conditionals
without functions.
Steps Involved:
oIterate through the array of products and display each product's code, name, and
price.
4. Accept User Orders:
Peoples Empowerment Group
ISBM COLLEGE OF ENGINEERING, NANDE, PUNE
DEPARTMENT OF FIRST YEAR ENGINEERING
Academic Year 2024-25
oUse a loop to accept product codes and quantities from the user.
oStore the selected products and their quantities in separate arrays.
5. Calculate the Bill:
o Iterate through the user's order, calculate the total cost for each product (quantity
* price), and accumulate the total bill amount.
6. Display the Bill:
o Display the detailed bill, including product names, quantities, unit prices, and the
total amount.
C Program:
#include <stdio.h>
#include <string.h>
struct Product {
int code;
char name[30];
float price;
};
int main() {
// Step 1: Define products
struct Product store[3] = {
{101, "Product A", 50.0},
{102, "Product B", 30.0},
{103, "Product C", 20.0}
};
order_codes[total_quantity] = code;
order_quantities[total_quantity] = quantity;
total_quantity++;
}
return 0;
}
Conclusion:
This experiment demonstrates how to simulate a class-like behavior in C using structures, and
how to process orders and generate a bill without using functions. The program effectively tracks
products, handles user orders, and calculates the total bill.