this program suppose to change decimal number to binary..
but..
when i run this program, somehow this does not terminate the loop.
I put break; command to terminate the loop.. but, it doesn't work i think..
but after manually terminate the loop, it displays right answer though..
Code:#include <stdio.h> main() { char bData[100]; int count=0; int inData; int i; int n = 1; int tmp; printf("Enter a number: "); scanf("%d\n", &inData); tmp = inData; count = 0; for(;;) { bData[count] = tmp%2; if(tmp < 2) break; tmp /= 2; count++; } printf("Binary number for %d is ",inData); for(i=count; i>=0; i--) { printf("%1d",bData[i]); } }