Since the average of two whole numbers can be a fraction, you should use a floating point type. For that, use double unless you have a specific reason to use float or long double.
Also, order of operations in C++ is approximately the same as in regular algebra's PEMDAS: Parentheses, Multiply and Divide, Add and Subtract. So, if you want to add two numbers and then divide by 2, you need parentheses around the division, as in (a + b)/2 rather that a+b/2.
Finally, C++ chooses the type of arithmetic to do based on the numbers used, not based ton the type of the result. For example 7/2 uses int values 7 and 2, so C++ does int division producing an integer result 3 (and discarding the remainder). If you want to compute in floating point, at least one of the the numbers must be floating point.
Put all that together and you get:
double result = (A + B) / 2.0;