Hi,
newbie here.....this is a problem from a textbook I've been using to teach myself C (by K N KING). The text does a lousy job of (NOT) commenting. It requires that the repeated elements, only, print after ("Repeated digit\n\n");
Code:#include<stdio.h> #define TRUE 1 #define FALSE 0 typedef int Bool; int main(){ Bool digit_seen[10]= {0}; int digit; long int n; printf("Enter a number: "); scanf("%ld", &n); while(n > 0){ digit = n % 10; if(digit_seen[digit]) break; digit_seen[digit]= TRUE; n/=10; } if (n > 0) printf("Repeated digit\n\n"); else printf("No repeated digit\n\n"); return 0; }