Patrz > 
Modulo
W bascomie to robiłem na potrzeby multipleksacji wyniku na wyświetlaczu led.
W C będzie zapewnie podobnie, łatwo to przepiszesz znając język.
Kod:
Wyswietl:
Portd = &B0000000
  If A = 4 Then
   Liczba = Wartosc \ 10000
   Portd = &B0010000
   Portb = Lookup(liczba , Tabela)
 Elseif A = 3 Then
   Liczba = Wartosc Mod 10000
   Liczba = Liczba \ 1000
   Portd = &B0001000
   Portb = Lookup(liczba , Tabela)
 Elseif A = 2 Then
   Liczba = Wartosc Mod 1000
   Liczba = Liczba \ 100
   Portd = &B0000100
   Portb = Lookup(liczba , Tabela)
 Elseif A = 1 Then
   Liczba = Wartosc Mod 100
   Liczba = Liczba \ 10
   Portd = &B0000010
   Portb = Lookup(liczba , Tabela)
   Portb.0 = 0
 Elseif A = 0 Then
   Liczba = Wartosc Mod 10
   Portd = &B0000001
   Portb = Lookup(liczba , Tabela)
 End If
 Incr A
 If A = 5 Then
   A = 0
 End If
Return
Tabela:
Data 129 , 235 , 37 , 41 , 75 , 25 , 81 , 171 , 1 , 11
 
Jest jeszcze inna metoda ale mniej elegancka.