Problem with the code

I have to get number of digits divided by 4 but I get just 0. What is wrong?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
  #include <iostream>
using namespace std;

int main() {
	int a;
	int b = 0;
	cin >> a;
	while (a > 0 && a < 0) {
		if (a > 99 && a < 1000 && a % 4 == 0)
			b = b++;
		cin >> a;
	}
	cout << b;
}
> b = b++;
This is undefined behaviour.

Just do one of these.
b++;
or
b += 1;
or
b = b + 1;

I have just tried it but I got the same result (0). Maybe there is another problem?
while (a > 0 && a < 0)
is equivalent to
never
So, what should I write if by the terms the code ends if I write 0. I hope you understand what I'm talking about
If you want to continue your while loop when you enter a number other than 0:
while (a != 0)
It finally works. Thanks a lot!
Topic archived. No new replies allowed.