No se esta cumpliendo la condicion, una forma de resolverlo seria asi:
#include <iostream>
using namespace std;
int main()
{
string am_pm;
do
{
cout << "\nEnter AM/PM: ";
getline(cin, am_pm);
}
while ((am_pm != "AM") && (am_pm != "PM"));
return 0;
}
Otra:
while (!((am_pm == "AM") || (am_pm == "PM")));
Otra:
while (((am_pm == "AM") || (am_pm == "PM"))==false);