Write a function programme to count odd elements present in an array | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Write a function programme to count odd elements present in an array

function

29th Mar 2018, 8:58 AM
Manisha Seth
Manisha Seth - avatar
3 Answers
+ 4
Have you tried doing something yourself? If yes, only then we shall help, provided you post the code and tell us about the errors you face.
29th Mar 2018, 12:42 PM
Kinshuk Vasisht
Kinshuk Vasisht - avatar
0
int arr[] = {1, 2, 3, 4, 5}; int oddNumbers = 0; int len = sizeof(arr) / sizeof(arr[0]); for (int i = 0; i < len; i++) { if (arr[i] % 2 != 0) { oddNumbers++; } }
29th Mar 2018, 12:42 PM
TurtleShell
TurtleShell - avatar
0
yes I have tried
29th Mar 2018, 2:21 PM
Manisha Seth
Manisha Seth - avatar