Answers for "while loop example c#"

C#
18

while loop in c#

int i = 0;

while (i < 10)
{
    Console.WriteLine("Value of i: {0}", i);

    i++;
}
Posted by: Guest on December-05-2019
1

While loop in c#

int i = 0;
while (i < 20) 
{
  Console.WriteLine(i);
  i++;
}
Posted by: Guest on July-03-2021
1

c# while loop

while(condition) 
{
   statement(s);
}
_______________EX.___________________
int a = 0;
while (a < 10)
{
	Console.WriteLine(a); //output>> 0 .. 1 .. 2 ........ 8 .. 9
	a++;
}
Posted by: Guest on January-08-2021
0

c# do while or

int sugar = 0;
int salt = 0;

do {
    bottle1.choose();
    bottle2.choose();
    if ((bottle1 == 'Sugar') && (bottle2 == 'Sugar'))
    {
        Console.Write("Sugar");
        sugar++;
    }
    else if ((bottle1 == 'Salt') && (bottle1 == 'Salt'))
    {
        salt++;
        Console.Write("Salt");
    }
    else
    {
        Console.Write("None");
    }
} while ((salt < 10) || (sugar < 10));
Posted by: Guest on April-24-2021
0

c# do while loop

do
{
    //code block
} while(condition);
Posted by: Guest on September-27-2021

C# Answers by Framework

Browse Popular Code Answers by Language