Hello,
I am trying to get my program to loop through an integer which will have 1-10 digits and check to make sure they all are 1's and 0's. At the moment, my code doesnt work. It gives me an answer as long as I enter a 1 or 0 as the last digit. I suspect it is a problem with my use of the modulus operator. Here is what I have:

Code:
while(control<10)
{
printf("Enter a binary number (1-10 digits):");
scanf("%d",&binary);

for(i=0;i<10;i++)
{
temp=binary%10;
if(temp==0||temp==1)
{
control+=1;
}
else
{
control=0;
break;
}
}
}
Thanks in advance for any and all help.

Evan


Reply Quote Top Bottom Edit