I am currently working on loops (for, while, and do while). I understand the basics and have successfully been able to do the basics with little to no effort.
I am currently working on a problem that goes just a touch beyond the basics where the end result will show a message (“Pass {0} in the loop”) where obviously the “{0}” is the number loop. However, I am trying to create a separate message for those number that are divisible by 5 (5, 10,15,20). Could I get a pointer in the right direction. I played around with the ideas of using an “if” statement or even a “foreach”, but have had no luck since yesterday finding a possible viable option or simply did not know how to phrase it properly. Below is my current code:
static void Main(string[] args)
{
int i = 1;
Console.WriteLine("Do while loop positive numbers");
do
{
Console.WriteLine("Pass {0} in the loop", i++);
} while (i <= 20);
Console.ReadLine();
}
Won’t write code for you but would like to give hint
You can use an
if conditioninside thedo while loopto check if it isdivisible by 5then display the special message. You can use%operator to check whether the number is divisible by some other number or not