Empty Output in Collatz Conjecture problem

Collatz conjecture problem: count number of steps until a number reaches "1". First number is number of inputs, followed by the inputs.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
#include <math.h>
using namespace std;
int main(){
int a, num;
cin>>a;
for (int i=0; i<a; i++){
/*if  (X modulo 2 = 0) then
    Xnext = X / 2
else
    Xnext = 3 * X + 1 */
   cin>>num;
   int steps =0;
    do { steps++;
    int b = num%2;
    if (b =0)
    num/=2;
    else
    num=3*num+1;
   } while (num!=1);
   cout<<steps<<" ";}
}



Output:
(Absolutely nothing)
line 16: if (b=0) should be if (b==0)
ohhhh, dang nabit.
Topic archived. No new replies allowed.