you must store the inflationrate in a variable with a bigger scope
int main()
{
float old_cpi, new_cpi;
char again;
float totalInflation = 0;
do
{
cout << "Enter the old and new consumer price indices: ";
cin >> old_cpi >> new_cpi;
float inflationRate = inflationRate(new_cpi, old_cpi); cout << "Inflation rate is " << inflationRate << endl;
totalInflation += inflationRate; cout << "Try again? (y or Y): ";
cin >> again;
} while((again == 'Y') || (again == 'y'));
cout << "Total inflation rate is " << totalInflation << endl;