For loop working in C# -
i writing program finds number of 1's in array.. "scanning" inside "for" loop takes place once.
for (i = 0; < 11; i++ ) { k = convert.toint32(console.read()); if (k==1) { ans++; } // console.writeline("i == {0}", i); } is normal in c# or doing wrong? tried search problem cannot find answers!
do
console.readline() instead of
console.read() when reach first console.read() inputstream saved first character returned read method. subsequent calls read method retrieve input 1 character @ time inputstream.
ex: first iteration:
k = console.read(); //you input "abc1", k = second iteration:
k = console.read(); // k = b and on. when last character in inputstream returned, next call console.read() display console again can input new string , hit enter.
Comments
Post a Comment