この質問が以前に聞かれた場合はお詫び申し上げます。私は周りを見回して解決策を見つけることができませんでした。私はCには新しいです。 私はフロートから%を得ることができないことを理解しています。私が2つの浮動小数点数を使用している場合、私はこの数学の残りをどのようにキャプチャすることができますか?エラー:バイナリ式のオペランドが無効です( 'float'および 'float')
#include <cs50.h>
#include <stdio.h>
#include <ctype.h>
#include <math.h>
/*
** Always use the largest coin possible
** keep track of coins used
** Print the final amount of coins
*/
int main (void)
{
float change;
int counter = 0;
int division;
//float rem;
float quarter = 0.25;
//float quarter = 0.25, dime = 0.10, nickel = 0.05, penny = 0.01;
/* Prompt user for an amont of change*/
do{
printf("How much do we owe you in change? ");
change = GetFloat();
}
while (change <= 0);
if (change >= quarter)
{
division = (change/quarter);
counter += division;
//change = (int)(change % quarter);
printf("change: %.2f\n", change);
printf("counter: %d\n ", counter);
}
return (0);
}
ありがとうございましたゲーリー、それはトリックでした、私はまた、あなたのrecomendationとこの変更= fmod(変更、四半期)ごとにfmodをチェックしました。動作します!再度、感謝します。 – Lucky500