void scanArea(int pos , int delTime) //this line promises not to return a value
{
int result;
myServo.write(pos);
delay(delTime);
result = sonar.ping_cm();
return result; //this line tries to return a value
}
Note the use of code tags (</> top/left of the editor) to make the code easy to deal with here.