我在c++中使用If else语句,我得到了相反的答案.查看更多信息
I used If else statement in C++, and i got opposite answer.. Check for more in info
Code::Blocks 10.06
我用下面的代码编写了一个程序来检查数字1是否能被数字2整除,然而,我输入数字1为8,数字2为4,它显示数字1不能被数字2整除,下面是我的代码,我也有程序运行的照片。关于我的程序
请告诉我是什么错误,请,我需要学习这个程序,我有一些目标:
#include <iostream>
using namespace std;
int main()
{
int a, b, d;
cout << "Hello guys" << endl;
cout << "Bucky's Student21 here" << endl;
cout << "today we are going to divide two numbers, and going to check whether one is divisible by other or not n";
cout << "If the number 1 is divisible by number 2, i will recognize it n";
cout << "enter number 1 n";
cin >> a;
cout << "enter number 2 n";
cin >> b;
d = a % b;
if (d = 0) {
cout << "number 1 is divisible by number 2 n";
}
else {
cout << "number 1 is not divisible by number 2 n ";
}
cout << "Hence now as you got to know whether the number 1 is divisible by number 2 or not n";
return 0;
}
将=替换为== i.e.
if(d==0)
{
cout<<"somethingn";
}
相关文章:
- 正在查找文档以获得PS4平台的C++中的设备信息
- 欧拉项目#8答案是大以获得有效答案
- 为什么在运行时没有向我们提供有关分段错误的更多信息?
- 首要问题的答案让值班员搞错了
- 奇怪的(对我来说)返回声明 - 在谷歌上找不到任何关于它的信息
- C++问题:用户认为数字1-100,程序提出问题不超过6次即可得到答案。无法正确
- 如何设置一个范围来提取我想要获得的信息
- 我试图制作一个程序,要求用户输入问题和答案,但程序循环不正确
- 使用 bfs 解决连接组件问题时得到错误的答案
- 系统参数信息A 与 SPI_GETMOUSE 返回 0
- 为什么 gcovr 会生成空覆盖率统计信息?
- 同一对象的"sizeof"的不同答案
- 我已经阅读了很多关于 2d 数组的信息,但我在作业中使用它时遇到了麻烦
- 递归求和任务的错误答案
- 我无法在Visual Studio代码中使用CIN输入答案,它说输入您的年龄,但它说只读文本编辑器如何解决这个问题?
- 为什么C++程序在太大时返回代码而不是答案?
- 不理解为什么代码没有产生所需的答案
- 为什么我在代码厨师的 CMPRSS 问题中得到 WA(错误答案)?
- 将信息输入到下面显示的结构向量中的正确语法/格式是什么
- 我在c++中使用If else语句,我得到了相反的答案.查看更多信息