I2C between two arduinos

I have two UNOS and I have wired them correctly for I2C ,the "Hello World" program works fine .

I have a keypad attached to one arduino(slave arduino ) . I get three integers {a,b,c} from the keypad and apply formula
z=(100a)+(10b)+c
I want to send integr z to the master arduino when it requests.

what should be my lines so that as I press keys on keypad on slave, integr z gets to the other Arduino and gets printed in the serial monitor. I am confused in the way the master arduino reads data in bits.
Here are my codes ,

**SLAVE CODE **

#include <Wire.h>
#include<Keypad.h>

const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
{'0','1','2','3'},
{'4','5','6','7'},
{'8','9','A','B'},
{'C','D','E','F'}
};
byte rowPins[ROWS] = {3, 2, 1, 0}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {7, 6, 5, 4}; //connect to the column pinouts of the keypad

//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);

void setup() {
Wire.begin(8); // join i2c bus with address #8
Wire.onRequest(requestEvent); // register event
}

void loop() {
delay(100);
}

// function that executes whenever data is requested by master
// this function is registered as an event, see setup()
void requestEvent() {

int a = customKeypad.waitForKey()-48 ; // -48 for character form to intger conversion .
int b= customKeypad.waitForKey()-48;
int c= customKeypad.waitForKey()-48;

int z= (100a)+(10b)+c;
Wire.write(z);

Master Code

#include <Wire.h>

void setup() {
Wire.begin(); // join i2c bus (address optional for master)
Serial.begin(9600); // start serial for output
}

void loop() {
Wire.requestFrom(8, 6); // request 6 bytes from slave device #8

while (Wire.available()) { // slave may send less than requested
int z = Wire.read(); // receive a byte as character
Serial.print(z); // print the character
}

delay(500);
}

Your slave code is not correct.

The behaviour of Wire.write() is asymmetric; its behaviour depends on whether you're a master or slave.

Calling write() from the master fills a 32-byte buffer which is transmitted when endTransmission() is called.

Calling write() from the slave sends the data immediately. You send one byte and extra bytes requested by the master are garbage.

To send multiple bytes from the slave, you have to fill your own buffer and send it all at once.

#include <Wire.h>
#include<Keypad.h>

const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
  {'0', '1', '2', '3'},
  {'4', '5', '6', '7'},
  {'8', '9', 'A', 'B'},
  {'C', 'D', 'E', 'F'}
};
byte rowPins[ROWS] = {3, 2, 1, 0}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {7, 6, 5, 4}; //connect to the column pinouts of the keypad

//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);

void setup() {
  Wire.begin(8);                // join i2c bus with address #8
  Wire.onRequest(requestEvent); // register event
}

void loop() {
  delay(100);
}

// function that executes whenever data is requested by master
// this function is registered as an event, see setup()
void requestEvent() {

  int a = customKeypad.waitForKey() - 48 ; // -48 for character form to intger conversion .
  int b = customKeypad.waitForKey() - 48;
  int c = customKeypad.waitForKey() - 48;

  int z = (100 * a) + (10 * b) + c;
  //Wire.write(z);
  uint8_t buffer[2];
  buffer[0] = z >> 8;//high byte of integer
  buffer[1] = z & 0xff; //low byte of integer
  Wire.write(buffer, 2);
}

Your master needs revision to receive the two bytes of the integer

#include <Wire.h>

void setup() {
  Wire.begin();        // join i2c bus (address optional for master)
  Serial.begin(9600);  // start serial for output
}

void loop() {
  Wire.requestFrom(8, 2);    // request 2 bytes from slave device #8

  while (Wire.available()) { // slave may send less than requested
    int z = Wire.read() << 8 | Wire.read(); //form int from two bytes
    Serial.print(z);
  }

  delay(500);
}