C Project WRC PDF
C Project WRC PDF
We would like to express our special thanks to our teacher of Department of Electronics and
Computer Engineering, Nabin Lamichanne, who gave the golden opportunity to do this wonderful
project related to C-Programming and also special thanks for continuous support, guidance,
appropriate supervision, valuable suggestion and constant encouragement to complete this
report. I am thankful to all teachers and the college.
We are thankful to our professor Nabin Lamichanne and all respected GURUs/Seniors of
Department of Electronics and Computer Engineering, Department of Geomatics Engineering,
IOE Western Regional Campus for showing us the beautiful path in our career development.
We are also thankful to our Director of Western Regional Campus for his beautiful benchmarking
nature to measure the knowledge and continuous support in our academic activities.
We are indebted to the family members for their support and encouragement in writing this
project. Without their support, this project would not have been completed. Thanks to
baniedustore for formatting this project in hard copy.
We will feel highly grateful to all the readers and testers for their constructive suggestions.
The healthy criticism will help to improve the content of this project. Feedbacks and suggestions
are welcome at [email protected], [email protected],
[email protected], [email protected]. For formatting project in hard copy
contact [email protected].
Enjal Shrestha,
Abhishek Yadav, Student of WRC
Pokhara
Baisakh, 2081
Table of content
1: Header file
2: Main function
3: User-defined function
4: Global variable, local variable
5: keyword
6: operator
7: Calling function
8: Called function
9: switch
10: Array
11: constant
12: Control statement
13: Formatted input and output
14: Unformatted input and output
15: Data types
ALGORITHM:
STEP 1: Start
STEP 2: Declare all the variable function required,
STEP 3: Ask the name of user,
STEP 4: Ask which type of food user want,
i.e. A for bref
B for lunch
C for dinner
STEP 5: If user chooses A goto 6,
B goto to 9,
C goto 12,
STEP 6: Display bf menu,
STEP 7: Enter the food code and quantity,
STEP 8: If want more goto step 6 else display bf bill,
STEP 9: Display lunch menu,
STEP 10: Enter the food code and quantity,
STEP 11: If want more goto step 9 else display bf bill,
STEP 12: Display dinner menu,
STEP 13: Enter the food code and quantity,
STEP 14: If want more goto step 12 else display bf bill,
STEP 15: END
//c program to show bill of wrc resturant
#include<stdio.h>
int again;
int total=0;
int bfrate[7][2]={ {0,30},
{1,35},
{2,40},
{3,20},
{4,15},
{5,20},
{6,30}
};
int lunchrate[7][2]={{0,80},
{1,120},
{2,20},
{3,120},
{4,150},
{5,160},
{6,30}};
int dinner_rate[7][2]={{0,65},
{1,50},
{2,70},
{3,80},
{4,65},
{5,110},
{6,50}};
int purchased[50][50];
int quantity[50][50];
int temp[50][50];
char name[50];
void bfast();
void lunch( );
void dinner();
void main_menu();
void display();
void lunch_menucard();
void dinner_menu();
void display_bf_bill();
void display_lunch_bill();
void display_dinner_bill();
void display_bfmenu();
void repeatbf();
void repeatlunch();
void repeatdinner();
char bfmenu[][100]={"Egg","Idli","Dosa","Upma","Milk","Tea","Puri"};
char lunchmenu[][100]={"Veg Biryani","Special meal","Chicken Roti","Aalu
Dal","Paneer Tikka","Veg mixed","Icecream"};
char dinnermenu[][100]={"Noodles","Tuppa","Burger","Pasta","Dhido","Paratha","salad
"};
main()
{
enter:
display();
printf("Enter your choice here : ");
scanf(" %c", &choice);
switch(choice)
{
case 'A':
case 'a':printf("\nBreakfast\n");
bfast();
break;
case 'B':
case 'b':printf("\nLunch\n");
lunch();
break;
case 'C':
case 'c':printf("\nDinner\n");
dinner();
break;
default:printf("\nWrong choice entered Please enter the valid choice!!\
n");
goto enter;
}
}
void display()
{
printf(" WELCOME TO WRC CAFETERIA \n ");
printf(" +============================+ \n\n");
printf(" && Please select the meal that you would like to purchase. && \n\n");
printf("\t\t [A] Breakfast\n");
printf("\t\t [B] Lunch\n");
printf("\t\t [C] Dinner\n");
}
void display_bfmenu()
{
printf(" WELCOME TO WRC CAFETERIA \n ");
printf(" +============================+ \n\n");
printf(" $ Breakfast Menu $ \n\n");
printf(" && Please select the food that you would like to purchase. && \n\n");
printf("\t\t [0] Egg - Rs 30.00\n");
printf("\t\t [1] Idli - Rs 35.00\n");
printf("\t\t [2] Dosa - Rs 40.00\n");
printf("\t\t [3] UPMA - Rs 20.00\n");
printf("\t\t [4] Milk - Rs 15.00\n");
printf("\t\t [5] Tea - Rs 20.00\n");
printf("\t\t [6] Puri - Rs 30.00\n");
}
void bfast() //Breakfast Menu Screen
{
int choice = 0; //local variables
int again = 0,amt=0;
int code,i;
display_bfmenu();
printf("\nEnter the code:: ");
scanf("%d", &code);
if(code>=0&&code<=6)
{
printf("\nEnter the quantity::");
scanf("%d",&quantity[code][1]);
purchased[code][1]= quantity[code][1]*bfrate[code][1];
total+=purchased[code][ 1];
}
else
{
printf("\nInvalid code entered, Please enter the code again!!!!\n\n");
bfast();
}
repeatbf();
}
void repeatbf()
{
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : "); //
Allows user to choose whether to check-out or buy anything else.
scanf("%d",&again);
if (again == 1)
bfast();
else if (again == 2 )
{
display_bf_bill();
}
else
{
printf("\n\n\t\tSorry Invalid Decision Entered\n");
repeatbf();
}
}
void display_bf_bill()
{
int i,j;
printf("\t\t ");
for(j=0;j<50;j++)
{
printf("_");
}
printf("\n\t\t |\t\t WRC RESTAURANT |\n");
printf("\t\t |\t\t BILLING INFORMATION |\n");
printf("\t\t |");
for(j=0;j<50;j++)
{
printf("_");
}
printf("|\n\t\t |\t\t\t\t\t\t |\n");
}
void display_lunch_bill()
{
int i,j;
printf("\t\t ");
for(j=0;j<50;j++)
{
printf("_");
}
printf("\n\t\t |\t\t WRC RESTAURANT |\n");
printf("\t\t |\t\t BILLING INFORMATION |\n");
printf("\t\t |");
for(j=0;j<50;j++)
{
printf("_");
}
printf("|\n\t\t |\t\t\t\t\t\t |\n");
}
void lunch() // Lunch Screen Menu
{
int choice = 0; //local variables
if(code>=0&&code<=6)
{
printf("\nEnter the quantity::");
scanf("%d",&quantity[code][1]);
purchased[code][1]= quantity[code][1]*lunchrate[code][1];
total+=purchased[code][ 1];
}
else
{
printf("\nInvalid code entered, Please enter the code again!!!!\n\n");
lunch();
}
repeatlunch();
}
void dinner() // Dinner Menu Screen
{
int choice = 0; //local variables
int again = 0,amt=0;
int code,i;
dinner_menu();
}
else
{
printf("\nInvalid code entered, Please enter the code again!!!!\n\n");
dinner();
}
repeatdinner();
}
void lunch_menucard()
{
printf(" WELCOME TO WRC CAFETERIA \n ");
printf(" +============================+ \n\n");
printf(" $ Lunch Menu $ \n\n");
printf(" && Please select the food that you would like to purchase. && \n\n");
printf("\t\t [0] Veg Biryani - Rs 80.00\n");
printf("\t\t [1] Special Meal - Rs 120.00\n");
printf("\t\t [2] Roti - Rs 20.00\n");
printf("\t\t [3] Dal tadka - Rs 120.00\n");
printf("\t\t [4] Paneer Tikka - Rs 150.00\n");
printf("\t\t [5] Veg Mix - Rs 160.00\n");
printf("\t\t [6] Ice cream - Rs 30.00\n");
printf("Enter your choice here : ");
}
void dinner_menu()
{
printf(" WELCOME TO WRC CAFETERIA \n ");
printf(" +============================+ \n\n");
printf(" $ Dinner Menu $ \n\n");
printf(" && Please select the food that you would like to purchase. && \n\n");
printf("\t\t [0] Noodle - Rs 65.00\n");
printf("\t\t [1] tuppa - Rs 50.00\n");
printf("\t\t [2] Burger - Rs 70.00\n");
printf("\t\t [3] Pasta - Rs 80.00\n");
printf("\t\t [4] Dhido - Rs 65.00\n");
printf("\t\t [5] Paratha - Rs 110.00\n");
printf("\t\t [6] Salad - Rs 50.00\n");
}
void repeatlunch()
{
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : "); //
Allows user to choose whether to check-out or buy anything else.
scanf("%d",&again);
if (again == 1)
lunch();
else if (again == 2 )
{
display_lunch_bill();
}
else
{
printf("\n\n\t\tSorry Invalid Decision Entered\n");
repeatlunch();
}
}
void repeatdinner()
{
}
else
{
printf("\n\n\t\tSorry Invalid Decision Entered\n");
repeatdinner();
}
}
Output:
OUTPUT NO.2
WHEN YOU ENTER WRONG INPUT: