-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBilling System using c
43 lines (34 loc) · 997 Bytes
/
Billing System using c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <stdio.h>
#include <string.h>
// Structure to represent a product
struct Product {
char name[50];
float price;
int quantity;
};
// Function to calculate the total cost for a product
float calculateTotal(struct Product product) {
return product.price * product.quantity;
}
// Function to display the bill for a product
void displayBill(struct Product product) {
printf("\nBill:\n");
printf("Product: %s\n", product.name);
printf("Price per unit: $%.2f\n", product.price);
printf("Quantity: %d\n", product.quantity);
printf("Total cost: $%.2f\n", calculateTotal(product));
}
int main() {
struct Product product;
// Input product details
printf("Enter product name: ");
scanf("%s", product.name);
printf("Enter price per unit: ");
scanf("%f", &product.price);
printf("Enter quantity: ");
scanf("%d", &product.quantity);
// Display the bill
displayBill(product);
return 0;
}
#Billing System using c