I am having a problem with the creating the following program: Create a program that will read in 2 letters, and then print the character half-way between the two. e.g. given A and G, it will print D. If there are an even number of characters between, then either of the 2 middle ones is OK I don't understand how I am suppose to have the program print out the character half-way between the two. Here is what I have. int main() { char ch, ch1, ch2; printf("Please enter in two characters.\n"); scanf("%c %c", &ch, &ch1); Any help is greatly appreciated.
Cast the characters to integers Add the integer values Divide by 2 Then recast back to characters. BUT you might want to add a few other details to stop things going wrong - such as first converting all characters to upper or lower case then making sure all values entered are between 'a' and 'z'
get the ascII code of both characters get the difference between the ascII code now divide the difference which you get between the ascII code that is your answer.