Advertisement
karlakmkj

Do...While Loop

Nov 19th, 2020 (edited)
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.75 KB | None | 0 0
  1. /*
  2. Create a timer where - when the timer finishes, an alarm will ring once. If you don’t click the button to turn it off, the alarm will repeat until it is turned off.
  3. */
  4.  
  5. using System;
  6.  
  7. namespace DoWhileLoop
  8. {
  9.   class Program
  10.   {
  11.     static void Main(string[] args)
  12.     {
  13.       bool buttonClick = true; //buttonClick = true means button is pressed to turn off, so loop will stop
  14.                                //buttonClick = false means the loop will keep going where statement will be printed repeatedly
  15.      
  16.       do {
  17.         Console.WriteLine("BLARRRRRRRRR");
  18.       } while(!buttonClick);   //condition where loop will stop when buttonClick is NOT true
  19.                  
  20.        Console.WriteLine("Time for a five minute break.");
  21.     }
  22.  
  23.   }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement