Hi people I need a help on call by reference this is the program I wrote but the thing is it wont call the amount of kegs and diet coke at the end please help..
Code:#include <stdio.h> #include <stdlib.h> int answer,guests=0,kegs,dietCoke,pizzas; void invitedquests(); void beverageorder(int); int foodorder(int); void allInfo(int,int,int,int); int main() { printf("Party Planing Assistant is pleased to be at your service!\n"); if you try it you will see what happens you get; ??? guests 0 kegs 0 diet coke ?? pizzas do { printf("a. Enter number of invited quests.\n"); printf("b. Determine beverage order.\n"); printf("c. Determine food order.\n"); printf("d. Display all information.\n"); printf("e. Quit.\n"); printf("Which do you want to choose?\n"); scanf("%c",&answer); printf("\n\n"); if(answer=='a') { invitedquests(); } else if(answer=='b') { beverageorder(guests); } else if(answer=='c') { pizzas=foodorder(guests); } else if(answer=='d') { allInfo(guests,kegs,dietCoke,pizzas); } else if(answer=='e') { } else { printf("please select a valid choice\n"); } }while(answer!='e'); system("pause"); return 0; } void invitedquests() { int quests; printf("How many guests?\n"); scanf("%d",&guests); } void beverageorder(int guests) { int beerDrinker,kegs,dietCokeDrinkers,dietCoke; if(guests==0) { printf("You must enter choice a before the beverage order can be computed.\n"); system("pause"); return 0; } else { beerDrinker=guests / 2; if(beerDrinker %20 != 0) { kegs=beerDrinker / 20 + 1; } else { kegs=beerDrinker / 20; } dietCokeDrinkers=guests / 2; dietCoke=dietCokeDrinkers / 6; } printf("%d\n",kegs); printf("%d\n\n\n",dietCoke); } int foodorder(int guests) { if(guests==0) { printf("You must enter choice a before the food order can be computed.\n"); system("pause"); return 0; } else { if(guests %4 != 0) { pizzas=guests / 4 + 1; } else { pizzas=guests / 4; } } return pizzas; } void allInfo(int guests,int kegs,int dietCoke,int pizzas) { printf("%d People\n%d Kegs of Beer\n%d Cases of Diet Coke\n%d Pizzas\n",guests,kegs,dietCoke,pizzas); }



LinkBack URL
About LinkBacks


