首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >在使用C++时面临“对二进制表达式('float‘和’float‘)无效的操作数

在使用C++时面临“对二进制表达式('float‘和’float‘)无效的操作数
EN

Stack Overflow用户
提问于 2019-04-27 10:52:15
回答 1查看 90关注 0票数 0

在做CS50问题集1-现金时,当我尝试编写代码时,我遇到了以下问题。我已经将变量声明为整数。为什么它还在发生?非常感谢你的帮助。

“二进制表达式的操作数无效('float‘和'float')”

代码语言:javascript
复制
#include <stdio.h>
#include <cs50.h>
#include <math.h>

int main(){
    float owe_in_dollars;
    float owe_in_cent;
    int coin_count = 0;
    do
    {
    owe_in_dollars = get_float("Change: ");
    }while(owe_in_dollars<0);
    owe_in_cent = (int)(owe_in_dollars*100);
    if (owe_in_cent%(int)25 > 0){
       coin_count++;
    }
    printf("%i", coin_count);
}
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55876843

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档