Using arrays in c to find repeated digits in an number (C)
<p>I need to make a program that checks to see if an entered value has any repeated digits. The user is asked to enter numbers until the entered value is 0. If there are any repeated digits, it displays "repeated digits" and then asks the user to enter another value. If there are no repeated digits, it displays "no repeated digits" and asks the user to enter another number. So far, this is what i have. It terminates the program when 0 is entered, but it always displays "no repeated digits" even if there are some.</p>

<pre><code>#include &lt;stdbool.h&gt;
#include &lt;stdio.h&gt;
int main(void)
{
bool digit_seen[10] = {false};
int digit;
long int n = 0;

printf("Enter a number: ");
scanf("%ld", &amp;n);

while(n &gt;= 0){

    if(n==0)
        break;
    while (n &gt; 0){
        digit = n % 10;
        if (digit_seen[digit]){
            digit_seen[digit] = true;
            break;
        }
        n /= 10;
    }
    if (n &gt; 0)
        printf("Repeated digit: %d\n", digit);
    else
        printf("No repeated digit\n");
    scanf("%ld", &amp;n);
    }

return 0;
}
</code></pre>