how can i use 7 segment 3digits 12 pin for display number

i connect my uno bord to hc-sr04 for measuring distance and below is this code(the part that measure the distance) ;
{but i dont know how to display it on my common anod, 3 digit ,12 pin 7 segment!
can any one help me with the code?}

code for only measure the distance:

int trig = 3; // pin 3 to Trig
int echo = 4; //pin 4 to Echo

void setup() {

Serial.begin(9600);
}

void loop()
{
long duration, cm;

pinMode(trig, OUTPUT);
digitalWrite(trig, LOW);
delayMicroseconds(2);
digitalWrite(trig, HIGH);
delayMicroseconds(5);
digitalWrite(trig, LOW);

pinMode(echo,INPUT);
duration = pulseIn(echo, HIGH);
cm = microsecondsToCentimeters(duration);

Serial.print(cm);
Serial.print("cm");
Serial.println();



}

long microsecondsToCentimeters(long microseconds)
{
return microseconds / 29 / 2;
}

What do you mean "part code"? It looks fairly complete to me but partial code is useless.

Go and read the instructions, then go back and modify your post (use the "More --> Modify" option to the bottom right of the post) to mark up the code as such so we can examine it conveniently and accurately.

If you do not do this, the code you post could well be garbled and is certainly scruffy so far.

Note: Also mark up any data in the same way. This includes error output that you get from the IDE.

And - before you post code, use "Auto Format" in the Tools menu to properly present the code.

Paul__B:
What do you mean "part code"? It looks fairly complete to me but partial code is useless.

Go and read the instructions, then go back and modify your post (use the "More --> Modify" option to the bottom right of the post) to mark up the code as such so we can examine it conveniently and accurately.

If you do not do this, the code you post could well be garbled and is certainly scruffy so far.

Note: Also mark up any data in the same way. This includes error output that you get from the IDE.

And - before you post code, use "Auto Format" in the Tools menu to properly present the code.

thanks ...
now can you help?