Question: Instructions Compile and Run the repdigit.c Explain the algorithm in that code. (What is it doing) Submit the code algorithm explanation in a word document.(
| Instructions | |
| Compile and Run the repdigit.c Explain the algorithm in that code. (What is it doing) Submit the code algorithm explanation in a word document.( explain the algorithm of the code in comments along the code and then paste that code with comments in a word document to submit) | |
#include
#define true 1
#define false 0
int main(void)
{
int digitCount[10] = {0};
int repeatedDigits = false;
int digit;
long n;
printf("Enter a number (for example 89065590): ");
scanf("%ld", &n);
while (n > 0)
{
digit = n % 10;
if (digitCount[digit] > 0)
{
repeatedDigits = true;
}
digitCount[digit]++;
n /= 10;
}
if (repeatedDigits)
{
printf("Repeated digit(s): ");
for (digit = 0; digit < 10; digit++)
{
if (digitCount[digit] > 1)
{
printf(" %d", digit);
}
}
printf(" ");
} else
{
printf("No repeated digit ");
}
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
