#include <stdio.h> struct CodeList { int code; int key; }; int main() { struct CodeList list[6*7]; int i = 1; int y =1; int x =1; for (char c = 'A'; c <='Z'; c++){ if (x > 6) { x =1; y++; } if (y > 7) { y =1; } list[i].key = c; list[i].code = (y * 10) + x; i++; x++; } //search char s = 'D'; for (i =0; i< 6*7; i++){ if(s == list[i].key){ printf("code %i", list[i].code);// 14 } } } By the way, you ignored the letter Q.