increment and decrement array value using keypad and LCD

Hello Everyone. I wanted to do programming to enter two digit number through keypad and display it on LCD. Also I want to program key 'A' as if it is entered, next number to that key should display on LCD .For example, if I enter 21 number through keypad so when I press key 'A', next number i,e 22 should be displayed on LCD..but i couldnt get ouput for program i have written'...excuse me if I asked any silly question...here is my code:

#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins

LiquidCrystal lcd(8, 9, 10, 11, 12, 13);//RS,EN,D4,D5,D6,D7

#include <Keypad.h>//header for keypad commands enabling

const byte ROWS = 4; // Four rows
int i=0;

const byte COLS = 4; // Three colum
int my_key [50]= {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,
                            17,18,19,20,21,22,23,24,25,26,27,28,29,
                            30,31,32,33,34,35,36,37,38,39,40,41,
                             42,43,44,45,46,47,48,49,50};

// Define the Keymap

char keys[ROWS][COLS] = {

  {'1','2','3','A'},

  {'4','5','6','B'},

  {'7','8','9','C'},

  {'#','0','*','D'}

};

// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.

byte rowPins[ROWS] = { 0, 1, 2, 3 };

// Connect keypad COL0, COL1 and COL2 to these Arduino pins.

byte colPins[COLS] = { 4, 5, 6, 7 };

//  Create the Keypad

Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup()

{

  for(int k=8;k<14;k++)

  {

    pinMode(k,OUTPUT);//pins 8-14 are enabled as output

  }

  lcd.begin(16, 2);//initializing LCD
 
  lcd.print(my_key[i]) ;
  
  int key_event();
   
}



void loop()

{

}

 int key_event()
 {
  
  char key = kpd.getKey();
 if (key != NO_KEY)
 {
 i=1; 

if (key == 'A' )
   {
    i=i+1;
    lcd.setCursor(0, 1);
    lcd.print(my_key[i]) ;
   }
else if(key== 'B')
   {
   i=i-1;
  lcd.setCursor(3, 1);
  lcd.print(my_key[i-1]);
   }
 }              
}

Why does

your code

have so much

white space?

Get rid of most of the blank lines.

int my_key [50]= {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,
                            17,18,19,20,21,22,23,24,25,26,27,28,29,
                            30,31,32,33,34,35,36,37,38,39,40,41,
                             42,43,44,45,46,47,48,49,50};

An array where every value in the array is 1 more than the index value is pointless.

  int key_event();

Why is there a function prototype in setup()? An incorrect function prototype, at that.

The setup() function is not telling the Keypad instance to call a function when a key is pressed, and loop() doesn't read the keypad, so you might as well not have connected it.

thank so much for replying..apologise for inconvenience...i have improved my program stii not getting right output..kindly help me with code.
my code:

#include <LiquidCrystal.h>

#include <Key.h>
#include <Keypad.h>
LiquidCrystal lcd(8, 9, 10, 11, 12, 13);
const byte ROWS = 4;
const byte COLS = 4;

char keys[ROWS][COLS] = {

  {'1','2','3','A'},

  {'4','5','6','B'},

  {'7','8','9','C'},

  {'*','0','#','D'}
};
byte rowPins[ROWS] = { 0,1,2,3 };
byte colPins[COLS] = { 4,5,6,7 };
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
int v1 = 0;
int v2 = 0;
void setup() {
lcd.begin(16, 2);
}
void loop() {  
   v1 = GetNumber();
   v2 = GetNumber();
}
int GetNumber()
{  
  int num = 0;
  char key = kpd.getKey();
   while(key != NO_KEY)
  {
   while(key != '#')
   {
      switch (key)
      {
         case NO_KEY:
            break;
            case '0': case '1': case '2': case '3': case '4':
            case '5': case '6': case '7': case '8': case '9':
            lcd.print(key);
            num = num * 10 + (key - '0');
            num = num + key;
            break;
            case '*':
            num = 0;
            lcd.clear();
            break;
            case 'A': 
            num = ++num;
            lcd.print(num);
            break;
       }
      key = kpd.getKey();      
   }
   return num;
  } 
}
 :)

stii not getting right output.

What do you get ?

num = num + key;

Why ?

What do you see if you print the intermediate values to the serial monitor in the GetNumber() function ?

when I press key 1 and A..I got output as 51 and for key 2 and A..I got output as 563

          num = num * 10 + (key - '0');
          num = num + key;

Work through with pencil and paper what the value of num will be when you press '1' starting with num = 0. Print num after the first line if it helps

You did not answer my question as to why the second line is there.

The extra blank lines are a copy/paste artifact with line-endings, not in the original code I suspect!