Answer false, why? | SoloLearn: Learn to code for FREE!

+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) ;

10/12/2017 1:03:36 PM

Валерия

3 Answers

New Answer

+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

+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); }

0

שלום