I need to loop the switch statement until 1 or 2 is entered as an input. Any help would be nice or sample code. I tried to use a while loop and it kept crashing. I tried a do while as well and it turned into an infinite loop so I must be doing something wrong.
int main (void)
{
    int choice; // choice to run program from start menu or quit
    
    while (1)
    {
        // Menu for entering resistor and capacitor values
        printf("Welcome to the 555 Timer Frequency and Duty Cycle Calculator\n");
        printf("Please enter two resistor values in between ");
        printf("1 kOhms and 100 kOhms and a capacitor value\n\n");
 
        //Start of menu 
        printf("Menu\n\n");
        printf("1. Continue\n");
        printf("2. Exit\n");
        scanf("%d", &choice); // User inputs value
        switch (choice)
        {
        case 1:
            resistor(); // Program resistor is run if 1 is input
            break;
        case 2:
            printf("Goodbye."); // Program ends if 2 is input
            break; // break is used to exit while loop
        default:
            printf("Sorry I do not understand\n\n"); 
            fflush(stdin);  /* clears input buffer to allow user to input a new value if anything other
                               than 1 or 2 is input into scanf  */
        }
        break;
    }
    return 0;
}
 
     
    