Action
Get two integers from the user, the first being the digit you want to know how many times it appears and the second being the contact number.
Input and Output
Entry:
Integer value A (between 1 and 9). Integer value B.
Output:
Number of times the digit A appears in B
#include <stdio.h>
int main(void)
{
int contaDigitos = 0, valor;
scanf("%d", &valor);
if (valor == 0) contaDigitos = 1;
else
while (valor != 0)
{
contaDigitos = contaDigitos + 1;
valor = valor / 10;
}
printf("%d\n", contaDigitos);
return 0;
}