From a01c63fbd4e125cf95310b0aa6b34cd09597c3a9 Mon Sep 17 00:00:00 2001 From: Gabriel Kaszewski Date: Sat, 27 Sep 2025 11:51:28 +0200 Subject: [PATCH] Add examples for do..while and foreach loops in programming book --- main.typ | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/main.typ b/main.typ index 3e2344f..c837284 100644 --- a/main.typ +++ b/main.typ @@ -317,7 +317,25 @@ while (shouldQuit) { } } -//TODO: do..while example & foreach example +string correctPin = "1234"; +string enteredPin = ""; + +do { + Console.Write("Please provide your PIN: "); + enteredPin = Console.ReadLine(); + + if (enteredPin != correctPin) { + Console.WriteLine("Incorrect PIN. Try again"); + } +} while (enteredPin != correctPin); + +Console.WriteLine("Correct PIN! Access granted."); + +string[] shoppingList = new string[] { "bread", "chicken", "butter"}; +Console.WriteLine("Your shopping list:"); +foreach (string product in shoppingList) { + Console.WriteLine($"- {product}"); +} ``` ==== Rezultat ==== Wyjaƛnienie