Q:

Calculate the sum of digits. If the number repeats itself, do not calculate it

My question is how do I check if a digit is repeated in an integer without using arrays?
For example: 123145... 1 is repeated twice. so the output should be 15 (1+2+3+4+5)
My current code is:
# include "stdio.h"
int main () {
  int input = 0;
  int sum = 0;
  int input = 0;
  int sum = 0;

  int digit;

  printf("Please enter a number: ");
  scanf("%d" ,&input);

  while(input > 0) {
    digit = input % 10;

    if(d0 < 1) {
        sum += digit;
        d0 = 1;
    }

    input /= 10;
  }

  printf("Sum of different digits is: %d\n", sum);
  return 0;
}

A:

This is a really dumb way to solve this problem, but it uses neither arrays nor bit vectors:
#include <stdbool.h>
bool numberHasDigit(unsigned n, unsigned digit) {
  while (n) {
    if (n % 10 == digit) return true;
    n /= 10;
  }
  return false;
}
unsigned sumOfUniqueDigits(unsigned n) {
  unsigned sum = 0;
  for (unsigned digit = 1; digit <= 9; ++digit) {
    if (numberHasDigit(n, digit)) sum += digit;
  }
  return sum;
}

It's dumb because using an array (or bit vector) of flags is much faster, particularly for big numbers, and the code is just as simple:
unsigned sumOfUniqueDigits(unsigned n) {
  bool seen[10] = {false};
  unsigned sum = 0;
  while (n) {
    unsigned digit = n % 10;
    if (!seen[digit]) {
      sum += digit;
      seen[digit] = true;
    }
    n = n / 10;
  }
  return sum;
}

