MPU-6050 6-Axis Gyro Acceleration Sensor showing output -1 always

Hi there,
I have been trying to get x,y and z values from MPU-6050 but i don’t know why it always showing -1. I have tried in UNO board. It gives perfect output in UNO board. But why the code doesn’t work in MEGA board?

#include<Wire.h>

const int MPU_addr=0x68; // I2C address of the MPU-6050
int16_t AcX,AcY,AcZ;
int a=0;
void setup() {

Wire.begin();
Wire.beginTransmission(MPU_addr);
Wire.write(0x6B); // PWR_MGMT_1 register
Wire.write(0); // set to zero (wakes up the MPU-6050)
Wire.endTransmission(true);

Serial.begin (9600);
}
void loop() {

// Accelerometer code here to detect X, Y and Z values
Wire.beginTransmission(MPU_addr);
Wire.write(0x3B); // starting with register 0x3B (ACCEL_XOUT_H)
Wire.endTransmission(false);
Wire.requestFrom(MPU_addr,14,true); // request a total of 14 registers
AcX=Wire.read()<<8|Wire.read(); // 0x3B (ACCEL_XOUT_H) & 0x3C (ACCEL_XOUT_L)
AcY=Wire.read()<<8|Wire.read(); // 0x3D (ACCEL_YOUT_H) & 0x3E (ACCEL_YOUT_L)
AcZ=Wire.read()<<8|Wire.read(); // 0x3F (ACCEL_ZOUT_H) & 0x40 (ACCEL_ZOUT_L)

Serial.print(a);
Serial.print(",");
Serial.print(AcX);
Serial.print(",");
Serial.print(AcY);
Serial.print(",");
Serial.println(AcZ);

delay(500);

a++;
}

Communications failure.

After reading How to use this forum, please edit your post to add code tags, post a wiring diagram, and clearly explain what the phrase "code doesn't work" means.