Timer to jump out of else ifstatement

Currently working on Zumo Robot with Intel Edison and HC-SR04 ultrasonic sensor. Making it to avoid dead path(distance <10cm) and navigate independently.

It is working but it is only turn one side(either right or left).

Is it possible to have the Robot turn lets say right first(if distance <10cm) for 90degree and if distance within this 90degree is still less than 10cm, the robot will then turn left for 180degree.

Is there any ways I can make the above happen with timer? To have a timer break out of the else if statement when 90degree is reach(i will calibrate the timing and speed) and continue the next line of else statement for left turn.

#include <ZumoMotors.h>

* This example uses the ZumoMotors library to drive each motor on the Zumo
* forward, then backward. The yellow user LED is on when a motor should be
* running forward and off when a motor should be running backward. If a
* motor on your Zumo has been flipped, you can correct its direction by
* uncommenting the call to flipLeftMotor() or flipRightMotor() in the setup()
* function.

ZumoMotors motors;
int trigPin = 13; //Connect pulse trigger pin to pin 13
int echoPin = 12; //Connect echo/receive pin to pin 12

void setup()
  Serial.begin (9600);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
// default Edison Arduino shield is PWM pins 3,5,6,9 jumpers and this function needed to change
// the order of the swizzle defines the PWM number, PWM0,1,2,3

// uncomment one or both of the following lines if your motors' directions need to be flipped

void loop()
  long duration, distance;
  digitalWrite(trigPin, LOW);   // initialise to low state
  digitalWrite(trigPin, HIGH);  // Trigger a high pulse
  digitalWrite(trigPin, LOW);   // Set to low pulse
  duration = pulseIn(echoPin, HIGH);  //determine the duration where a high pulse is received
  distance = (duration/2) / 29.1; //Speed of sound  = 340m/s, 1 cm = 29.4 microsecond
  Serial.println(" cm");

  if (distance>10)
  else  if (distance<=10)

Is there a way to make this happen? Thank You

What do you mean "break out of an if statement". The code doesn't stay in the if. It reads the if statement, evaluates the expression, and if it is true runs some code and moves on. What you need to do is rethink the if statements. Make yourself some state variables to keep track of what is going on in your program so your if statements can check more than just the distance.

Okay thank you. I will think over agian.

i will calibrate the timing and speed

Which will change as the tires wear or the material that the tires run on changes or the speed of the robot changes. Turning an exact amount is NOT done based on time. It is based on feedback from appropriate sensors.