count specific number in array powershell

C++
$grades = @($g1, $g2, $g3, $g4, $g5, $g6)

$countCredit = for($x=0; $grades -gt 50 ; $x++) { $x.count }
Write-Host "Credits Earned: " $countCredit 
$countCredit = for($x=$grade.count; $x -gt 50 ; $x++) { $grades[$x] } 
Write-Host "Credits Earned: " $countCredit
Source

Also in C++: