When I enter any characters except numbers in the "Enter your choice" it will infinitely loop. For example: Typing in a character. Result As, you can see it will just infinitely loop, unless I input a number between 1 to 10 as represented for each product choice. Or when typing in any number not between numbers 1 to 10, it will be recognized as an Invalid choice. P.S. Newbie Coder.
This is the code of the program.
#include <stdio.h>
int main(void)
{
    int choice, quantity, total = 0, price = 0;
    char end;
    do
    {
        printf("\nWelcome to our store!\n\n");
        printf("Welcome to our store!\n");
        printf("Please select a product from the following list:\n");
        printf("1. Oishi Prawn Crackers - 7 PHP\n");
        printf("2. Piattos - 16 PHP\n");
        printf("3. Coca-Cola - 40 PHP\n");
        printf("4. Sting Energy Drink - 25 PHP\n");
        printf("5. Gatorade - 43 PHP\n");
        printf("6. Nature Spring 500mL - 10 PHP\n");
        printf("7. KitKat - 30 PHP\n");
        printf("8. Snickers - 44 PHP\n");
        printf("9. Oishi Prawn Crackers - 7 PHP\n");
        printf("10. M&M's - 80 PHP\n");
        printf("Enter 0 to finish.\n");
        printf("\nProduct                 Quantity   Price\n");
        printf("----------------------------------------\n");
        do
        {
            printf("Enter your choice: ");
            scanf(" %d", &choice);
            if (choice == 0)
            {
                break;
            }
            printf("Enter the quantity: ");
            scanf(" %d", &quantity);
            switch (choice)
            {
            case 1:
                printf("Oishi Prawn Crackers        %d        %d\n", quantity, price = 7 * quantity);
                total += 7 * quantity;
                break;
            case 2:
                printf("Piattos                     %d        %d\n", quantity, price = 16 * quantity);
                total += 15 * quantity;
                break;
            case 3:
                printf("Coca-Cola                   %d        %d\n", quantity, price = 40 * quantity);
                total += 40 * quantity;
                break;
            case 4:
                printf("Sting Energy Drink          %d        %d\n", quantity, price = 25 * quantity);
                total += 25 * quantity;
                break;
            case 5:
                printf("Gatorade 500mL              %d        %d\n", quantity, price = 43 * quantity);
                total += 43 * quantity;
                break;
            case 6:
                printf("Nature Spring 500mL         %d        %d\n", quantity, price = 10 * quantity);
                total += 10 * quantity;
                break;
            case 7:
                printf("KitKat                      %d        %d\n", quantity, price = 30 * quantity);
                total += 30 * quantity;
                break;
            case 8:
                printf("Snickers                    %d        %d\n", quantity, price = 44 * quantity);
                total += 44 * quantity;
                break;
            case 9:
                printf("M&M's                       %d        %d\n", quantity, price = 40 * quantity);
                total += 40 * quantity;
                break;
            case 10:
                printf("Pringles                    %d        %d\n", quantity, price = 80 * quantity);
                total += 80 * quantity;
                break;
            default:
                printf("Invalid choice.\n");
                break;
            }
        } while (choice != 0);
        printf("----------------------------------------\n");
        printf("Total cost: %d PHP\n", total);
        printf("Thank you for shopping with us!\n");
        printf("\nWant to Buy Again?\n");
        printf("Y if Yes\n");
        printf("Type any key if No\n");
        scanf(" %c", &end);
        switch (end) {
        case 'Y':
            printf("\nOK!\n");
            break;
        default:
            printf("\nBYE!\n");
            break;
        }
    } while (end == 'Y');
    return 0;
}
So, I typed in numbers from 1 to 10 and it seems to recognize every product and it will ask for the quantity. And typing in any numbers it will do what it should and will output Invalid Choice. I tried changing the variables expecting it to be fixed but it won't work at all. It seems that I overlooked something but I don't know where.
 
     
    