By Kimberly Chin

Cognizant Technology Solutions Corp. reported lower profit in the fiscal second quarter as the effects of the Covid-19 pandemic as well as a ransomware attack early in the quarter dented sales.

Cognizant said it has seen an improvement in revenue and booking through May and June. Client demand has picked up in cloud and enterprise-application services, IT modernization and digital engineering, the company said.

The professional-services company said net profit was $361 million, or 67 cents a share, down from $509 million, or 90 cents a share, a year earlier. Adjusted earnings were 82 cents a share. Analysts surveyed by FactSet expected a profit of 69 cents an adjusted share.

The company lowered costs and selling, general and administrative expenses, but recorded higher restructuring and depreciation and amortization expenses.

Sales fell to $4 billion from $4.14 billion a year earlier. Analysts were expecting $3.83 billion in revenue. While it saw sales declines across most of its segments in the quarter, the bright spot was its healthcare segment which rose 2% driven by life-science clients from its Zenith Technologies acquisition.

The company said the decline in its products and resources segment was coming from customers in industries hit hard by the pandemic like retail, consumer goods, travel and hospitality. Meanwhile, its decision to exit certain content-related business negatively affected its communication, media and technology segment, Cognizant said.

Write to Kimberly Chin at kimberly.chin@wsj.com