Logo 
Search:

C Programming Forum

Ask Question   UnAnswered
Home » Forum » C Programming       RSS Feeds

Stationery Shop Database

  Asked By: Abdul    Date: Oct 16    Category: C Programming    Views: 2002
  

I have to create a stationery sho database with the following guidelines


1)Display catalogue of what is present in shop with the following data:
Product name
Product code
Quantity
Price

2)Generate a bill with the following data:
Customer name
Product code
Product name
Quantity
Price
Total

3)Provision to remove number of items from stock after generating the bill.

4)If stock is empty, then display "Stock is empty".

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Abdul Hakeem     Answered On: Oct 16

This is the my code. I have a problem with the billing function.










#include<stdio.h>
#include<stdlib.h>
#include<conio.h>

struct item
{
int pdt_code;
char item_name;
float price;
int stock;
struct item *next;
};

typedef struct item node;

struct invoice
{
char cust_name;
char prod_name;
int quantity;
int price;
int total;
struct invoice *next;
};

typedef struct invoice bill;


void add(); /*Function to add stock details in the beginning */
void Delete(); /*Function to delete stock details at any position */
void display(); /*Function to display stock */
void billgen(); /*Function to generate bill */
void stock(); /*Function to display stock after bill is generated */

node *head=NULL;


void main()
{
int ch;
clrscr();
printf("\n1.Add\n2.Delete\n3.Catalogue\n4.Display_bill\n5.Display_stock\n6.Exit\n");
do
{
printf("Enter the option:\t");
scanf("%d",&ch);
switch(ch)
{
case 1: add();
break;
case 2: if(head==NULL)
printf("Database is empty\n");
else
Delete();
break;
case 3: if(head==NULL)
printf("Database is empty\n");
else
display();
break;

case 4: billgen();
break;
case 5: stock();
break;

case 6:exit(0);

default: printf("\n Invalid Choice\n");
}
}
while(ch<=6);
getch();
}


void add()
{
node*temp;
temp=(node*)malloc(sizeof(node));

printf("Enter the Product code\n");
scanf("%d",&temp->pdt_code);
printf("Enter the Product name\n");
scanf("%s",&temp->item_name);
printf("Enter the Product price\n");
scanf("%d",&temp->price);
printf("Enter the Product Stock\n");
scanf("%d",&temp->stock);
temp->next=head;
head=temp;
}


void Delete()
{
int i =1, pos;
node *cur=head, *temp;
printf("\n enter the position to be deleted");
scanf("%d", &pos);
if(pos==1)
{
temp = head;
head = head->next;
free(temp);
}
else
{
while(pos!=i+1 && cur->next!=NULL)
{
cur=cur->next;
i++;
}
if(pos==i+1)
{
temp = cur->next;
cur->next=temp->next;
printf("\n Deleted product code is %d \n", temp->pdt_code);
printf("\n Deleted Item name is %s \n", temp->item_name);
printf("\n Deleted Product Price is %d \n", temp->price);
printf("\n Deleted stock is %d \n", temp->stock);
free(temp);
}
}
}


void display()
{
node*temp=head;
while(temp!=NULL)
{
printf("%d\n",temp->pdt_code);
printf("%s\n",temp->item_name);
printf("%f\n",temp->price);
printf("%d\n",temp->stock);
temp=temp->next;
}
}


void billgen(int quantity, int price)
{
node*temp=head;
while(temp!=NULL)
{
int quantity, price, total;
printf("Enter the product price and quantity:\n");
scanf("%d%d",price,quantity);
total=quantity*price;

printf("%s\n",temp->bill.cust_name);
printf("%s\n",temp->bill.prod_name);
printf("%d\n",temp->bill.quantity);
printf("%d\n",temp->bill.price);
printf("%d\n",temp->bill.total);
}
}


void stock();
{
node*temp=head;
while(temp!=NULL)
if(stock==NULL)
{
printf("\nThere is no stock\n");
}
else
{
int quantity, stock;
printf("Stock available:\t");
scanf("%d%d",price,stock);
stock=stock-quantity;

printf("%d\n",temp->stock);
}
}

 
Didn't find what you were looking for? Find more on Stationery Shop Database Or get search suggestion and latest updates.




Tagged: