Count in octal: Difference between revisions

Content added Content deleted
(→‎{{header|Go}}: added floating point example)
(Added implementation in C#.)
Line 82: Line 82:
return 0;
return 0;
}</lang>
}</lang>
=={{header|C sharp|C#}}==
<lang csharp>using System;


class Program
{
static void Main()
{
var number = 0;
do
{
Console.WriteLine(Convert.ToString(number, 8));
} while (++number > 0);
}
}</lang>
=={{header|C++}}==
=={{header|C++}}==
This prevents an infinite loop by counting until the counter overflows and produces a 0 again. This could also be done with a for or while loop, but you'd have to print 0 (or the last number) outside the loop.
This prevents an infinite loop by counting until the counter overflows and produces a 0 again. This could also be done with a for or while loop, but you'd have to print 0 (or the last number) outside the loop.