December 23, 2024
Find the missing letter

Belajar Bahasa C – Find the missing letter

Write a method that takes an array of consecutive (increasing) letters as input and that returns the missing letter in the array.

You will always get an valid array. And it will be always exactly one letter be missing. The length of the array will always be at least 2. The array will always contain letters in only one case.

Example:

['a','b','c','d','f'] -> 'e'
['O','Q','R','S'] -> 'P'

(Use the English alphabet with 26 letters!) Have fun coding it and please don’t forget to vote and rank this kata! :-). I have also created other katas. Take a look if you enjoyed this kata!

The link problem is here.

Solution:

char findMissingLetter(char array[], int arrayLength)
{
  char miss, start;
  int i;

  start = array[0];
  for (i = 0; i < arrayLength; i++)
  {
    if (start != array[i])
    {
      miss = start;
      break;
    }
    start = start + 1;
  }
  return miss;
}

Rajo Intan

Blogger, pemiliki Onestring Lab, menulis artikel terkait teknologi informasi dan pendidikan. Web Developer, berpengalaman lebih dari 20 tahun mengembangkan berbagai aplikasi dan sistem informasi. Kerjasama kontak di onestringlab@gmail.com atau https://forms.gle/xAGKkpi6B3BzJyzk7

View all posts by Rajo Intan →

Leave a Reply

Your email address will not be published. Required fields are marked *

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
100% Free SEO Tools - Tool Kits PRO