0

An array of integer is given.

All elements ending in the number 4 are reduce by half

16th Nov 2020, 2:27 PM
Doshik Help please
Doshik Help please - avatar
2 Réponses
+ 3
Traverse the array and use an if statement to check whether number%10 == 4, if so then do number = number/2.
16th Nov 2020, 2:47 PM
Avinesh
Avinesh - avatar
+ 3
You can use linq and write just one command line arr.ToList().Where(w => w.Value%4 == 0).ForEach(s => s.Value /= 2);
16th Nov 2020, 4:28 PM
hossein B
hossein B - avatar