+ 2

How to build do while?

6th Mar 2017, 5:52 PM
QoRamtin Builder & Commander
QoRamtin Builder & Commander - avatar
3 Respostas
+ 10
We use the do-while loop to check its condition at the end of the loop. A do...while loop is similar to a while loop, except that a do...while loop is guaranteed to execute at least one time. Some example class Program { static void Main(string[] args) { int a = 5; do { Console.WriteLine("value of a: {0}", a); a = a + 1; } while (a < 10); } } Result: value of a: 5 value of a: 6 value of a: 7 value of a: 8 value of a: 9
7th Mar 2017, 12:07 PM
George Fox
+ 4
int i=0; int sum=0; do{ sum+=i; i++; } while(i<10)
7th Mar 2017, 12:09 PM
Puspa R. Rijal
Puspa R. Rijal - avatar
+ 1
Is the first answer to this question written in Java?
31st Dec 2017, 8:43 PM
Francisco
Francisco - avatar