C++ 我的程序运行并返回0,但它不';I don’我给它的数据不能显示

C++ 我的程序运行并返回0,但它不';I don’我给它的数据不能显示,c++,math,numbers,cout,C++,Math,Numbers,Cout,当我构建并运行代码时,它立即返回0,表示编程成功,但我希望它显示100到200之间可被4整除的所有数字。 这是我的密码 #include <iostream> using namespace std; int main() { int num = 200; int snum; cout<<"The following numbers are all divisble by 4 and are inbetween 100 and 200\n"; while(num&l

当我构建并运行代码时,它立即返回0,表示编程成功,但我希望它显示100到200之间可被4整除的所有数字。

这是我的密码

#include <iostream>

using namespace std;

int main()
{
int num = 200;
int snum;

cout<<"The following numbers are all divisble by 4 and are inbetween 100 and 200\n";
while(num<99)
{
    snum = (num % 4) ;

    cout<<snum<<endl;
    cout<<num<<endl;

            if(snum = 0)
            {
                cout<< num << endl;
            }
            else
            {

            }
            num--;
}



return 0;
}
#包括
使用名称空间std;
int main()
{
int num=200;
int snum;

cout由于条件

(num<99)
(snum = 0)
另外,if语句的条件

(num<99)
(snum = 0)
snum
设置为零,总是返回零,所以您可能是指

(num>99)
(snum == 0)

while
条件应为
while(num>99)
而不是
while(num>99)
{
snum=num%4;//不需要括号
如果(snum==0)
{

std::cout您将
num
设置为200:

int num = 200;
只有当数值小于99时,才运行循环:

while(num<99)
在C语言中,用
==
检查相等性:

if(snum == 0)
事实上,您所拥有的(
if(snum=0)
)永远不会为真,因此您的if语句永远不会被执行