why cant the program return to menu function when the user entered 'y'?Code:#include<stdio.h> int fiction(); int art(); int engin(); int child(); int study(); void display(); char menu(); int main() { char option; printf("WELCOME TO ONLINEBUKU.COM\n"); menu(); system("pause"); return 0; } char menu() { char option; printf("WHICH CATEGORY YOU WANT TO CHOOSE?\n"); printf(" A: FICTION BOOKS\n"); printf(" B: ART AND CRAFT BOOKS\n"); printf(" C: ENGINEERING & SCIENCE BOOKS\n"); printf(" D: CHILDREN BOOKS\n"); printf(" E: ISLAMIC STUDIES BOOKS\n"); printf("\n"); printf("YOUR OPTION:"); scanf("%c",&option); printf("\n"); switch(option) { case 'A': fiction();break; case 'B': art();break; case 'C': engin();break; case 'D': child();break; case 'E': study();break; } } int fiction() { char ans; int books,amount; float pre=0.0; printf("\tOPTION A: FICTION BOOKS \t\t PRICE (UNIT)\n"); printf("\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"); printf("\t1.Zeus King Of The Gods RM 58.20\n"); printf("\t2.Penny Century: A Love and Rockets Book RM 78.90\n"); printf("\t3.Map of the Invisible World RM 34.60\n"); printf("\t4.Jodi Picoult: House Rules RM 32.90\n"); printf("\tPlease key in your choice:"); scanf("%d",&books); printf("\tPlease enter the amount:"); scanf("%d",&amount); switch(books) { case 1: pre=amount*58.2;break; case 2: pre=amount*78.9;break; case 3: pre=amount*34.6;break; case 4: pre=amount*32.9;break; } printf("\tThe total price is %0.2f\n",pre); printf("\tPress y-continue/n-stop:"); scanf("%d",&ans); if(ans=='y') { menu(); } else { display(); } } int art() { char ans; int books,amount; float pre=0.0; printf("\tOPTION B: ART AND CRAFT BOOKS \t\tPRICE (UNIT)\n"); printf("\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"); printf("\t1.Connoisseur'S Guide To Antique Silver RM 58.20\n"); printf("\t2.Best Ever Craft Project Book RM 38.50\n"); printf("\t3.Encyclopedia Of Acrylic Techni Ques RM 89.60\n"); printf("\t4.Teach Yourself Calligraphy RM 100.50\n"); printf("\tPlease key in your choice:"); scanf("%d",&books); printf("\tPlease enter the amount:"); scanf("%d",&amount); switch(books) { case 1: pre=amount*58.2;break; case 2: pre=amount*38.5;break; case 3: pre=amount*89.6;break; case 4: pre=amount*100.5;break; } printf("\tThe total price is %0.2f\n",pre); printf("\tPress y-continue/n-stop:"); scanf("%d",&ans); if(ans=='y') { menu(); } else { display(); } } int engin() { char ans; int books,amount; float pre=0.0; printf("\tOPTION C: ENGINEERING & SCIENCE BOOKS PRICE (UNIT)\n"); printf("\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"); printf("\t1.Solar Power For Your Home RM 71.80\n"); printf("\t2.Chemical Engineering Thermodynamic RM 69.90\n"); printf("\t3.Marine Electrical Technology RM 128.60\n"); printf("\t4.Engineering Design Reliability RM 112.90\n"); printf("\tPlease key in your choice:"); scanf("%d",&books); printf("\tPlease enter the amount:"); scanf("%d",&amount); switch(books) { case 1: pre=amount*71.8;break; case 2: pre=amount*69.9;break; case 3: pre=amount*128.6;break; case 4: pre=amount*112.9;break; } printf("\tThe total price is %0.2f\n",pre); printf("\tPress y-continue/n-stop:"); scanf("%d",&ans); if(ans=='y') { menu(); } else { display(); } } int child() { char ans; int books,amount; float pre=0.0; printf("\tOPTION D: CHILDREN BOOKS \t PRICE (UNIT)\n"); printf("\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"); printf("\t1. Kasih Sahabat RM 11.90\n"); printf("\t2. Adikku Istimewa RM 12.00\n"); printf("\t3. 101 Akhlak Rasulullah RM 32.00\n"); printf("\t4. Legasi Blok E: Kebangkitan Kuasa RM 14.50\n"); printf("\tPlease key in your choice:"); scanf("%d",&books); printf("\tPlease enter the amount:"); scanf("%d",&amount); switch(books) { case 1: pre=amount*11.9;break; case 2: pre=amount*12.0;break; case 3: pre=amount*32.0;break; case 4: pre=amount*14.5;break; } printf("\tThe total price is %0.2f\n",pre); printf("\tPress y-continue/n-stop:"); scanf("%d",&ans); if(ans=='y') { menu(); } else { display(); } } int study() { char ans; int books,amount; float pre=0.0; printf("\tOPTION E: ISLAMIC STUDIES BOOKS \tPRICE (UNIT)\n"); printf("\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"); printf("\t1. Mencari Islam di China RM 23.30\n"); printf("\t2. From Cat Steven to Yusuf Islam RM 20.00\n"); printf("\t3. Ketika Hatiku Ingin Berhijrah RM 25.50\n"); printf("\t4. Taatilah Allah, Rasul & Ulil Amri RM 12.50\n"); printf("\tPlease key in your choice:"); scanf("%d",&books); printf("\tPlease enter the amount:"); scanf("%d",&amount); switch(books) { case 1: pre=amount*23.3;break; case 2: pre=amount*20.0;break; case 3: pre=amount*25.5;break; case 4: pre=amount*12.5;break; } printf("\tThe total price is %0.2f\n",pre); printf("\tPress y-continue/n-stop:"); scanf("%d",&ans); if(ans=='y') { menu(); } else { display(); } } void display() { printf("Good Bye!"); }
do i have to use a loop instead of if-else?