when the user press 'q' this program prints "do you want to shop more?" but i want that the program always ask itself about shopping more.how to do it?Code:#include <stdio.h> #include <stdlib.h> #include <conio.h> int main(){ char choice,shopping=1; int x,sugar=350,jam=250,shampoo=199,bread=50 ,eggs=90,subtotal1=0,subtotal2=0,subtotal3=0,subtotal4=0,subtotal5=0,total; while(shopping) {printf("WELCOME TO NUST DHABBA\n"); printf("World's biggest Departmental store\n"); printf("Enter choice\n"); printf("[1] for 1 kg sugar bag\n"); printf("[2] for Jam\n"); printf("[3] for XYZ Shampoo\n"); printf("[4] for Bread\n"); printf("[5] for 1 dozen eggs\n"); printf("[q] to quit shoping\n"); total=subtotal1+subtotal2+subtotal3+subtotal4+subtotal5; choice=getch(); if((choice=='q')||(choice=='Q')) exit(0); if(choice=='1') { printf("shopped:1 kg sugar bag=350 rupees\n",sugar); printf("how many?\n",x); scanf("%d",&x); subtotal1=sugar*x; printf("Sub total:sugar=%d\n",subtotal1); getch(); } if(choice=='2'){ printf("Shopped:Jam=250\n",jam); printf("How many?\n",x); scanf("%d",&x); subtotal2=jam*x; printf("Sub total:Jam=%d\n",subtotal2); getch (); } if(choice=='3') { printf("shopped:XYZ shampoo\n",shampoo); printf("How many?\n",x); scanf("%d",&x); subtotal3=shampoo*x; printf("Sub total:shampoo=%d\n",subtotal3); getch (); } if(choice=='4'){ printf("Shopped:Bread\n",bread); printf("How many?\n",x); scanf("%d",&x); subtotal4=bread*x; printf("Sub total:Bread=%d\n",subtotal4); } if(choice=='5') { printf("shopped:dozen eggs\n",shampoo); printf("How many dozens you want?\n",x); scanf("%d",&x); subtotal5=eggs*x; printf("Sub total:eggs=%d\n",subtotal5); getch();} printf("Do you want to shop more Y/N?\n"); if ((choice!='y')) shopping=1; total=subtotal1+subtotal2+subtotal3+subtotal4+subtotal5; printf("Total is %d\n",total); getch (); } }
moreover,any suggestions to make it more simple and it uses lesser space.