How WOuld I Make It Check All Three Sides And Then Make A Decision

I Have An Ultrasonic Sensor (4pins)
I Have an Arduino Mega 2560

#include <Servo.h> // Including Servo Library To Use Servo

int echo = 51;  // Ultrasonic Sensor Echo Pin
int pingPin = 51;  // Ultrasonic Sensor Trigger Pin
int inPin = 53;
int motorA = 12;  //Motor A Direction Control
int motorB = 13;  // Motor B Direction Control
int motorAS = 3;  //PWM Speed Control
int motorBS = 11; //PWM Speed Control
int motorAB = 9;  //PWM Speed Control
int motorBB = 8;
int mspeed = 200;  // Defines Normal Speed
long microseconds;
int dangerdist = 1;


Servo myservo;

void setup() {
pinMode(echo, INPUT);
//pinMode(trigger, OUTPUT);
pinMode(motorA, OUTPUT);
pinMode(motorB, OUTPUT);
pinMode(motorAS, OUTPUT);
pinMode(motorBS, OUTPUT);
pinMode(motorAB, OUTPUT);
pinMode(motorBB, OUTPUT);
Serial.begin(9600);
myservo.attach(22); 
}


void loop() {
check();
}


/*   
Chasis Direction Controls
_________________________
*/
void forwards() {
  digitalWrite(motorA, HIGH);
  digitalWrite(motorB, LOW);
  digitalWrite(motorAS, HIGH);
  digitalWrite(motorBS, HIGH);
}
void backwards() {
 digitalWrite(motorA, LOW);
 digitalWrite(motorB, HIGH);
 analogWrite(motorAS, mspeed);
 analogWrite(motorBS, mspeed);  
}

void right() {
digitalWrite(motorA, HIGH);
digitalWrite(motorB, LOW);
analogWrite(motorAS, 0);
digitalWrite(motorBS, HIGH);
}

void left() {
  digitalWrite(motorA, HIGH);
  digitalWrite(motorB, LOW);
  analogWrite(motorAS, mspeed);
  analogWrite(motorBS, 0);
}

/*
Servo Controls
_______________
*/

void servo_left(){
  myservo.write(75);
}

void servo_center(){
  myservo.write(110);
}

void servo_right(){
  myservo.write(145);
}

/*
Ultrasonic Sensor Controls
__________________________
*/

void check(){
  
  // Check Surroundings
long duration, inches;
servo_center();
delay(1000);
digitalWrite(pingPin, LOW);
delayMicroseconds(2);
digitalWrite(pingPin, HIGH);
delayMicroseconds(10);
digitalWrite(pingPin, LOW);
delayMicroseconds(2);
pinMode(pingPin, OUTPUT);

pinMode(inPin, INPUT);
duration = pulseIn(inPin, HIGH);

delay(100);

inches = microsecondsToInches(duration);

if (inches <= 40 ) 
{
 right(); 
}
else{
  forwards();
}
}
long microsecondsToInches(long microseconds){
 // Accroding To Parrallax's Data Shate There Are 73.746 nicroseconds Per Inch
return microseconds / 74 / 2;
}

What is "it" that should check all three sides (of what)? How would "it" then use that data to make a decision?

It is referring to my servo that will move the ultrasonic sensor. Then make a decision for the safest route possible.

You have to move the servo to each position. You have to take a reading at each position. Then, you decide what to do based on those readings.

delayMicroseconds(2);
pinMode(pingPin, OUTPUT);

pinMode(inPin, INPUT);

What is that pinMode statement doing for you. That pin should already be an output because you have just used it to pulse your sensor.

At a rough guess how about going in the direction that reads the most distance.

Is this a homework assignment? I find it hard to believe you wrote all that code but don't know that bit.

No, Im Trying To Teach Myself, Im Reading Alot Of Articles But Im Having Trouble Making a Void Statement To Decide Which Way Is Best.

Making a Void Statement

void is the type of data it returns, you want a function not a statement and it would be good if it returned the direction to go in.
In each of the three directions store the distance in an array or three separate variables. Then simply check which of the three readings represents the longest distance using if statements. And then turn in that direction if any change is needed.