Sum and average of odd/even elements of an array

preview_player
Показать описание
Program to print, find sum and calculate average of the odd and even elements of an array

If you liked this video, please like, share and subscribe.
Follow me on Instagram @thenuttyprofessorchannel for updates.
Рекомендации по теме
Комментарии
Автор

A common doubt was the use of the variable 'c' in this program. We have an input of 'n' elements into the array of which not all 'n' values are even/odd. So since (average of odd elements) = (sum of all odd elements)/(number of odd elements), I used the variable 'c' to count how many elements are actually odd. And so avg = sum/c and not sum/n. The same goes for even elements too.

thenuttyprofessor