My specified range has to be 1 to 10 inclusive, without the negative values terminating the program, and no other prompts are allowed
Modify your main function
do{
int ex = scanf("%f%f", &r, &h); //scanf returns int
if (ex == 0)
{break;}
if(r<=0 || r>10){
printf("Invalid radius: %.2f\n",r);
continue;
}
if(h<=0 || h>10){
printf("Invalid height: %.2f\n",h);
continue;
}
// hence above conditions failed means you have given desired input
// need not to check any conditions
volume = volCyl(r,h);
k = k++;
printf(" Cylinder %d radius %.2f height %.2f volume %.2f\n",k,r,h,volume);
toth = toth + h;
}while(r>0 && h>0);
if(k>0) // check this other wise divide by zero will occur
{
avgh = toth/k;
printf("Total Height: %.2f\n",toth);
printf("Average Height: %.2f\n",avgh);
}