Determining and printing a remainder in ardunio IDE

Making a ultrasonic tape measure, using a LV Maxbotiz ez sensor.

using the following code I can output my reading IN feet or inchs. I was wondering using the arduino IdE how do I code and print my remainder so My sensor will display correctly

Example, Even though I am reading 4 foot 5 inchs from my sensor I dont know how to display 4 and X inches.

Here is the code I got from max Botix

I read something about the modulo operator, but I am unsure how to correctly integrate this into my example.

const int anPin1 = 0;
long distance1;

void setup() {
  Serial.begin(9600);  // sets the serial port to 9600
}

void read_sensors(){
  /*
  Scale factor is (Vcc/512) per inch. A 5V supply yields ~9.8mV/in
  Arduino analog pin goes from 0 to 1024, so the value has to be divided by 2 to get the actual inches
  */
  distance1 = analogRead(anPin1)/2;
}

void print_all(){
  Serial.print("S1");
  Serial.print(" ");
  Serial.print(distance1 /12);
  Serial.print("feet");
  Serial.println();
}

void loop() {
  read_sensors();
  print_all();
  delay(50); 
}

I will likely figure it out, but I can see there are a ton of people on here with WAY more coding time then my self.

Thanks in advance

https://www.arduino.cc/en/Reference/Modulo

Modulo works like any other math operator like + - / or *. It does just what you want, it gets the remainder of a division.

For example:

int val = 32;

int quotient = val / 12;  // quotient has the value 2
int remainder = val % 12;  // remainder now has the value 8

For example:

Or

   int feet = distance / 12;
   int inches = distance - (feet * 12);

(assuming distance is in inches)

PaulS: Or

   int feet = distance / 12;
   int inches = distance - (feet * 12);

(assuming distance is in inches)

Isn't modulo faster than this ?

guix: Isn't modulo faster than this ?

Does it really matter?

Isn't modulo faster than this ?

No.