There's two possibilities here. Either you never get to the printf
, or the output never gets to you.
For the first case, are you sure that k == 1
and num % j == 0
? Giving us the actual numeric values values in your test might help. Note that if k
is a floating-point number that's the result of a computation it might be very slightly off from 1.0, and the condition would return false.
For the second case, how are you testing this? That should print out the value of j
, but it doesn't flush the output, so if the program terminates abnormally or the console goes away at the end of the program or something you may not see it. Try printf("%d\n", j);
or even fflush(stdout);
to make sure the output is visible on your console or terminal.