验证C++的乘法值?

1 c++ validation

我必须做一个测试,其中一个数字必须是500 的倍数,

      do{
            cout << "Input Price[price>0|price multiple of 500]: ";
            cin >> price;
            cin.sync(); cin.clear();
        } while (price<1 || price>5000);
Run Code Online (Sandbox Code Playgroud)

代码仍然不完整,我只需要添加以下验证.我该怎么办?

还有什么是这种验证的合适术语?我很难确定标题.

qua*_*dev 7

在测试中添加以下内容:

price % 500 == 0
Run Code Online (Sandbox Code Playgroud)

这通常称为模数(找到两个数之间除数的余数):如果您的价格是500的倍数,那么价格和500之间的除法的余数为0.