anti virus

anti virus

  • NA
  • 17
  • 3.5k

while loop that is repeated

Dec 14 2018 5:38 PM
 while loop that is repeated if i is less than twice j. Inside the loop double the value of i and decrement j.
Count the number of times the loop is executed
 
using System;

namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
int i = 1; int j = 10;
int count = 0;

while(i<(2*j))
{
i++;

count++;
}

Console.WriteLine("The loop repeated " + count + " times and now j is " + j + " and i is " + i);
}
}
}

Answers (3)