The while loop is one of the important looping construct, that is being widely used in C sharp programming language
it three things are important.
1. Initialization
2. Increment/Decrement
3.Termination
These are the important characteristics of any loop. Initialization represents the starting position from there your loop will be started. In the below exampleint i=0refers to initialization of while loop.i++refers to increment/decrement and finallywhile(i<10)refers to the termination of while loop.
using System;
namespace While { class Program { static void Main(string[] args) { int num, Result, i;
Console.WriteLine("Enter a number"); num = Convert.ToInt32(Console.ReadLine()); i = 1; while (i <= 10) { Result = num * i; Console.WriteLine("{0} x {1} = {2}", num, i, Result); i++; } 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.
The while loop is one of the important looping construct, that is being widely used in C sharp programming language
it three things are important.
1. Initialization
2. Increment/Decrement
3. Termination
These are the important characteristics of any loop. Initialization represents the starting position from there your loop will be started. In the below example int i=0 refers to initialization of while loop. i++ refers to increment/decrement and finally while(i<10) refers to the termination of while loop.