我想創建一個程序來完成標題所說的內容,通過5整除意味着整數值。這裏是迄今爲止,雖然它是不完整的代碼: -創建一個程序來告訴用戶一個數字是否可以被整除5
#include <iostream>
using namespace std;
int main()
{
int x;
cout << "Enter a number to see if its divisable by 5" << endl;
cin >> x;
x = x/5;
if (x ==)
{
cout << "yes it is divisible by 5 and the value is" << x << endl;
}
else
{
cout << "no its not divisable by 5" << endl;
}
return 0;
}
我堅持以放什麼的if語句,使其認識到,如果分配給X的數量是5或不能整除。有人可以幫助我嗎?
我會試試這個,但是x/5不一定等於0,它必須等於任何整數。你的代碼能適應這個嗎? –
@FlewittConnor是的,檢查更新 –
謝謝你這個作品。所以模數(%)是餘數? –