The goals all came in the last 10 minutes of the first half as the pace of the Algerians and the accuracy of their passes cut open the Tanzanian defence almost at will.
The victory meant Algeria matched hosts Egypt and Morocco with a full haul of nine points in the group stage, while Tanzania finished bottom as they returned to the tournament for the first time since 1980.
Algeria will face a third-placed finisher in the last 16.
Algeria made nine changes, having already secured qualification after a morale-boosting win over Senegal in their previous match, using the opportunity to rest regulars before the start of the knockout stages at the weekend.
But even with a fresh look, Algeria were far more polished than Tanzania and went almost immediately on the attack with teenager Hichem Boudaoui missing a good opportunity inside the opening two minutes.
There were several half chances that followed before Slimani ran onto a long ball between two defenders and finished with aplomb for the 35th minute opener.
The striker then played a clever one-two to set up Ounas for the second goal four minutes later.
On the stroke of halftime, Slimani was again the provider with a long pass that allowed Ounas to outsprint the defence, round the goalkeeper and finish from a tight angle.
Algeria, who brought Riyad Mahrez on for the last 20 minutes, lacked the same urgency in the second half but were still dominant.
Tanzania's English-based striker Adi Yussuf might have grabbed a consolation goal in the last minute but headed narrowly over the bar.
Meanwhile, Senegal's Sadio Mane had a penalty saved but later scored his first two goals at this year's Africa Cup of Nations as they beat Kenya 3-0 to reach the round of 16 on Monday.
Mane's spot kick was stopped by Patrick Matasi in the first half and it looked to be a costly miss as Senegal struggled to break down a resilient Kenyan side who could still qualify.
But it all changed after Ismaila Sarr broke the deadlock in the 63rd minute and Mane then added two more, the second of his brace also from a penalty which this time he buried confidently.
Senegal, who finished second in Group C with six points behind Algeria on nine, will face Uganda in the knockout round on Friday, while Kenya, who have three points, must wait to see if they progress as one of the best third-placed teams.
Senegal coach Aliou Cisse had been reluctant to allow Mane to take the second penalty but said it was the correct decision.
"He was right, it's important that he takes that responsibility, and it's important that he gets that confidence," Cisse told reporters.
There was plenty of drama in the first half and Senegal claimed they should have been awarded a penalty when Victor Wanyama appeared to handle following a corner, but Egyptian referee Ghead Grisha emphatically waved play on.
Shortly afterwards, Kenya's Musa Mohammed clumsily tripped Saliou Ciss and this time there was no let-off for the Harambee Stars as the official pointed to the spot.
However, Matasi, who plays his club football in Ethiopia, dived to his right to save Liverpool forward Mane's spot kick.
Matasi also saved a shot from Henri Saivet just before the penalty and tipped Sarr's effort onto the bar on the stroke of halftime to keep Kenya's goal intact.
But the keeper was at fault when the defence was finally breached in the 63rd minute as he failed to intercept a cross and Sarr hooked the ball in. After that it was easy for Senegal.
Nine minutes later, they cleared a corner and broke down field, Mane was released and drilled the ball past Matasi.
By now Kenya looked ragged and Philemon Otieno showed their desperation as he tripped Sarr, conceded a penalty and was sent off. Mane stepped up and made no mistake second time around.
"We were not so far, but not so close. If you commit a mistake, you are punished immediately when you play Senegal," said Kenya coach Sebastien Migne.
"For one hour, we created some problems, some difficulties at least. Now, we need to wait and we expect and hope for some help. We will learn... we have learned a lot, I think."