do while loop treats same as while loop but only differences between them is that, do while executes at least one time. The code executes first then check for specified loop condition. But in while loop, the specified loop condition evaluated first then executes the code.
using System; namespace dowhile { class Program { static void Main(string[] args) { int Number, i, Result; Number = 12; i = 1; do { Result = Number * i; Console.WriteLine("{0} x {1} = {2}", Number, i, Result); i++; } while (i <= 12);
Console.ReadLine(); } } }
Join MindStick Community
You need to log in or register to vote on answers or questions.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
do while loop treats same as while loop but only differences between them is that, do while executes at least one time. The code executes first then check for specified loop condition. But in while loop, the specified loop condition evaluated first then executes the code.