Can't get to Servo code to work

i only wanted to execute sweep code 2 times what is wrong here nothing is happening all the pins are correct to

the code:

#include <Servo.h>

Servo myservo;

void setup() {
myservo.attach(9);

servoTurn(2);
}

void loop() {

}

void servoTurn(int x){
int pos = 0;
for(int i;i<x;i++){
for (pos = 0; pos <= 180; pos += 1) {

myservo.write(pos);
delay(15);
}
for (pos = 180; pos >= 0; pos -= 1) {
myservo.write(pos);
delay(15);
}

}

Thanks for everybodies responses

Well right now it doesn't even compile because you're short a }

But when you balance the { and }, you didn't initialise i in the for:

for (int i=0; i < x; i++)

How are you powering the servo? You should not try to connect it to the +5V pin since motors tend to draw too much power. That can cause the Arduino to reset.