US general merchandise retailer JC Penney has swung to a second-quarter loss and says it won't meet full-year forecasts on the back of lower than expected sales.