[Solved] C programming do while with switch case program


Use a do...while loop like this:

int I = 1; //Initialize to some non-zero number to prevent UB
printf("Enter 0 to quit \n");
do{
    if (scanf("%d",&I) != 1) //If invalid data such as characters are inputted
    {
        scanf("%*[^\n]");
        scanf("%*c");    //Clear the stdin
    }
} while(I!=0); //Loop until `I` is not 0 

This piece of code will loop until the user enters 0. You can change this code according to your needs. If you want your switch in this, copy your posted code after the scanf.

solved C programming do while with switch case program