#include<stdio.h>
#include<conio.h>
#include<windows.h>
void bill(char name[], char add[], int o[],char *s[],int p[]);
void main()
{
int i,o[10],p[]={40,60,55,85,95,90,130,25,20,10};
char *s[]={"Rice ","Fried Rice ","Sahi Paneer ","Chicken Kosa ","Chicken Kabab","Chilli Chicken","Mutton Kosa","Salad ","Soft Drinks","Sweets "};
char name[20],add[20];
char a,b;
printf("\t ****************WELCOME TO HOTEL LOVELY***************** \n");
printf("\t\t\tNH-1, PHAGWARA, PUNJAB\n");
printf("\t\t\t MOBILE-+91-9872300000\n");
printf("\n\t Enter Your Name:\t ");
gets(name);
printf("\t Enter Your Address:\t");
gets(add);
printf("\n\t **** DEAR CUSTOMER, TODAY WE HAVE SPECIALY ITEM FOR YOU ****\n\n");
printf(" \t ITEMS \t\t\t PRICE\n");
for(i=0;i<10;i++)
{
printf(" %d. %s \t\t %d (Per Plate)\n",i+1,s[i],p[i]);
}
printf("\nDear customer, would you like to give order?(y for yes/ n for no) : ");
scanf("%c",&a);
if(a=='y'||a=='Y')
{
printf("\n\t Your Order ......");
printf("\n \t Please Select Your Order(Enter Quantity only):\n");
for(i=0;i<10;i++)
{
printf("\n %d \t %s \t\t :\t",i+1,s[i]);
scanf("%d",&o[i]);
}
printf("\n\n \t In 10 Minutes, food will be on the Table");
printf("\n \t Please Wait....!\n");
printf("\n\n\n\t Want bill, Sir...?(y for yes)\t:\t ");
scanf(" %c",&b);
if(b=='y'||b=='Y')
{
bill(name,add,o,s,p);
}
}
printf("\n\n\n\t\t Thank You Sir, Visit Again...!");
printf("\n___________________________________________________DEVELOPED BY BIKASH THAPA\n");
}
void bill(char name[], char add[], int o[],char *s[],int p[])
{
int i,tot=0;
system("cls");
printf("\n\t******************WELCOME TO HOTEL LOVELY********************* \n");
printf("\t\t\t NH-1, PHAGWARA, PUNJAB\n");
printf("\t\t\t MOBILE-+91-9872350000\n");
printf("\n\t Customer Name: \t");
puts(name);
printf("\t Customer Address: \t");
puts(add);
printf("\n\t Your Today's Bill is.....\n");
printf(" \t\t\t ITEMS \t\t\t\t TOTAL");
printf("\n\t____________________________________________________________________");
for(i=0;i<10;i++)
{
if(o[i]!=0)
{
printf("\n\t\t %s \t(%d X %d)\t\t %d",s[i],o[i],p[i],o[i]*p[i]);
}
}
printf("\n\t____________________________________________________________________");
for(i=0;i<10;i++)
{
tot=tot+o[i]*p[i];
}
printf("\n\t Your Total Billing amount is\t:\t\t\t %d\n",tot);
}
--------------------------This blog is specially created for the people who loves program coding and want to learn more about it------------------------------------ ---------------------------------------------------------------------KEEP CALM AND START CODING PROGRAMS----------------------------------------------------------------
Sunday, February 19, 2017
hotel bill in c.
#Program to insert data and display data using double linked list
#include<stdio.h>
#include<conio.h>
struct node
{
int data;
struct node *p;
struct node *n;
};
struct node *first=NULL;
struct node *last=NULL;
void insert(void);
void displayB(void);
void displayL(void);
void main()
{
while(1)
{
int ch;
printf("1.To insert Data\n");
printf("2.To Display Data From beginning\n");
printf("3. To Display Data from End\n");
printf("4. Exit\n");
printf("Enter Choice\n");
scanf("%d",&ch);
switch(ch)
{
case 1:
insert();
break;
case 2:
displayB();
break;
case 3:
displayL();
break;
case 4:
exit(1);
break;
default:
printf("Wrong input\n");
break;
}
}
}
void insert(void)
{
int v;
printf("Enter value\n");
scanf("%d",&v);
struct node *ptr;
ptr=(struct node *)malloc(sizeof(struct node));
ptr->data=v;
if(first==NULL)
{
ptr->p=NULL;
ptr->n=NULL;
first=last=ptr;
}
else{
ptr->p=last;
ptr->n=NULL;
last->n=ptr;
last=ptr;
}
}
void displayB()
{
struct node *ptr;
ptr=first;
printf("\nThe list of Data from Beginning are;");
while(ptr->n!=NULL)
{
printf("\n%d",ptr->data);
ptr=ptr->n;
}
printf("\n%d\n",ptr->data);
}
void displayL(void)
{
struct node *ptr;
ptr=last;
printf("\nThe list of data from Last are:");
while(ptr->p!=NULL)
{
printf("\n%d",ptr->data);
ptr=ptr->p;
}
printf("\n%d\n",ptr->data);
}
#include<conio.h>
struct node
{
int data;
struct node *p;
struct node *n;
};
struct node *first=NULL;
struct node *last=NULL;
void insert(void);
void displayB(void);
void displayL(void);
void main()
{
while(1)
{
int ch;
printf("1.To insert Data\n");
printf("2.To Display Data From beginning\n");
printf("3. To Display Data from End\n");
printf("4. Exit\n");
printf("Enter Choice\n");
scanf("%d",&ch);
switch(ch)
{
case 1:
insert();
break;
case 2:
displayB();
break;
case 3:
displayL();
break;
case 4:
exit(1);
break;
default:
printf("Wrong input\n");
break;
}
}
}
void insert(void)
{
int v;
printf("Enter value\n");
scanf("%d",&v);
struct node *ptr;
ptr=(struct node *)malloc(sizeof(struct node));
ptr->data=v;
if(first==NULL)
{
ptr->p=NULL;
ptr->n=NULL;
first=last=ptr;
}
else{
ptr->p=last;
ptr->n=NULL;
last->n=ptr;
last=ptr;
}
}
void displayB()
{
struct node *ptr;
ptr=first;
printf("\nThe list of Data from Beginning are;");
while(ptr->n!=NULL)
{
printf("\n%d",ptr->data);
ptr=ptr->n;
}
printf("\n%d\n",ptr->data);
}
void displayL(void)
{
struct node *ptr;
ptr=last;
printf("\nThe list of data from Last are:");
while(ptr->p!=NULL)
{
printf("\n%d",ptr->data);
ptr=ptr->p;
}
printf("\n%d\n",ptr->data);
}
Tuesday, February 7, 2017
//program to add node in a link list
#include<stdio.h>
#include<conio.h>
struct node
{
int data;
struct node *next;
};
struct node *first=NULL;
struct node *last=NULL;
void insert(int);
void display(void);
void main()
{
int v,ch;
while(1)
{
printf("1. Insert Data\n");
printf("2. Display List \n");
printf("3. Exit\n");
printf("Enter your choice\n");
scanf("%d",&ch);
switch(ch)
{
case 1:
printf("Enter Value to insert\n");
scanf("%d",&v);
insert(v);
break;
case 2:
printf("The list is\n");
display();
break;
case 3:
exit(1);
break;
default:
printf("Wrong input");
break;
}
}
}
void insert(int v)
{
struct node *ptr;
ptr=(struct node*)malloc(sizeof(struct node));
ptr->data=v;
if(first==NULL)
{
first=last=ptr;
ptr->next=NULL;
}
else
{
last->next=ptr;
ptr->next=NULL;
last=ptr;
}
}
void display()
{
struct node *ptr;
if(first==NULL)
{
printf("No Record Found\n");
}
else if(first==last)
{
printf("%d\n",first->data);
}
else
{
for(ptr=first;ptr!=last;ptr=ptr->next)
{
printf("%d\n",ptr->data);
}
printf("%d\n",last->data);
}
}
#include<stdio.h>
#include<conio.h>
struct node
{
int data;
struct node *next;
};
struct node *first=NULL;
struct node *last=NULL;
void insert(int);
void display(void);
void main()
{
int v,ch;
while(1)
{
printf("1. Insert Data\n");
printf("2. Display List \n");
printf("3. Exit\n");
printf("Enter your choice\n");
scanf("%d",&ch);
switch(ch)
{
case 1:
printf("Enter Value to insert\n");
scanf("%d",&v);
insert(v);
break;
case 2:
printf("The list is\n");
display();
break;
case 3:
exit(1);
break;
default:
printf("Wrong input");
break;
}
}
}
void insert(int v)
{
struct node *ptr;
ptr=(struct node*)malloc(sizeof(struct node));
ptr->data=v;
if(first==NULL)
{
first=last=ptr;
ptr->next=NULL;
}
else
{
last->next=ptr;
ptr->next=NULL;
last=ptr;
}
}
void display()
{
struct node *ptr;
if(first==NULL)
{
printf("No Record Found\n");
}
else if(first==last)
{
printf("%d\n",first->data);
}
else
{
for(ptr=first;ptr!=last;ptr=ptr->next)
{
printf("%d\n",ptr->data);
}
printf("%d\n",last->data);
}
}
Subscribe to:
Comments (Atom)