+ 4

Answer false, why?

int[] a={1,0,5,2,8}; int b=8; bool k=true; foreach(int t in a) { k=k&&t<b; } Console. Write(k) ;

12th Oct 2017, 1:03 PM
Š’Š°Š»ŠµŃ€Šøя
Š’Š°Š»ŠµŃ€Šøя - avatar
3 Answers
+ 4
Because k=k&&t<b; for the last element of the list, 8, k=true&&8<8=true&&false=false If you change last element from 8 to 7 then result is TRUE
12th Oct 2017, 1:56 PM
Daniel
Daniel - avatar
+ 2
try that way: int[] a={1,0,5,2,8}; int b=8; bool k=true; foreach(int t in a) { k=k&&t<b; Console. WriteLine(k); }
12th Oct 2017, 5:12 PM
Rem
0
שלום
30th Jan 2019, 10:14 AM
Aryeh Shebson