I was given this problem of finding out the alphabet between 2 given alphabets, and this is the code i came up with....and the problem is that I get an ASCII value instead of and alphabet. For example, when I input AZ, the proper answer should be M but I get 77 which is ASCII value of M.....

#include <iostream>
using namespace std;

int main()
{	
	char c1, c2, c3 = (c1 + c2)/2;
	cout << "Enter 2 Alphabet: ";
	cin.get (c1);
	cin.get (c2);
	cout << "The Alphabet in between is " << (c1 + c2)/2 <<endl;
}

You would cast it like this

cout<<"The letter in the middle is " << (char)((c1+c2)/2) << endl;

Your usage of the word alphabet is incorrect however. Alphabet denotes the entire list of letters. The way you use the word is what "letter" means.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.