このwhileループに関するCプログラミングで真の偽を説明できる人はいますか?whileループに関するcプログラミングで真または偽
0が偽であり、while (!Done)
が真であり、done = 1も真であるとしたら、done = 1はどのようにループを "中断"するか終了するか?
done=0;
while(!done)
{
c=getchar();
switch(c)
{
case '1':
printf("Beverage $8.00\n");
total+= 8;
break;
case '2':
printf("Candy $3.00\n");
total+= 3;
break;
case '3':
printf("Sandwich $5.00\n");
total+= 5;
break;
case '4':
printf("Hot Dog. $2.00\n");
total+= 2;
break;
case '5':
printf("Popcorn $6.00\n");
total+= 6;
break;
case '=':
printf("Your choices are finished.\n");
printf("The total is:$%.2f\n", total);
printf("Please pay the cashier.\n");
done=1;
break;
default:
printf("I don't understand your choice, please try again.\n");
}
}
return (0);
}
を終了ブール値として 'done'は' true'です。したがって、 '!done'は' false'になり、ループは終了します。 –