The S&P 500 and Nasdaq Composite indexes posted their second straight weekly declines as the tech sector continued to sag and inflation readings exceeded forecasts.