What is the output of this code? int[ ] arr = {8, 2, 6}; int y=0; foreach (int x in arr) { y+=x/2; } Console.Write(y); | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the output of this code? int[ ] arr = {8, 2, 6}; int y=0; foreach (int x in arr) { y+=x/2; } Console.Write(y);

17th Nov 2016, 7:21 PM
Avishek Mukherjee
Avishek Mukherjee - avatar
8 Answers
+ 3
What is the output of this code? const arr = ['3', '5', '8']; console.log( arr.find(x => x == 8).repeat(2) ); ans : 88
7th Jun 2020, 1:20 AM
Frederick John Suerte
Frederick John Suerte - avatar
+ 2
88
14th Mar 2020, 2:00 PM
Nagesh L Rupnar
Nagesh L Rupnar - avatar
+ 1
8/2 + 2/2 + 6/2 = 8, no ?
17th Nov 2016, 7:29 PM
Volts
Volts - avatar
0
8
17th Nov 2016, 7:29 PM
Tamás Téglás
Tamás Téglás - avatar
0
it's 8
18th Nov 2016, 3:14 AM
Bharath
0
8/2 + 2/2 + 6/2 = 4+0+3 = 7, so why 8 ? It's a mistake
16th Feb 2018, 6:06 PM
AndrejB
0
But 2/2 = 1, not 0...
16th Feb 2018, 6:11 PM
Volts
Volts - avatar
0
88
3rd Dec 2020, 7:58 PM
El Maslohi Hassan