From 8a7cf65aa4e76d90773d991fc0df3aecebfeb2d8 Mon Sep 17 00:00:00 2001 From: Geir Okkenhaug Jerstad Date: Mon, 18 Nov 2024 13:04:45 +0100 Subject: [PATCH] Oppgaver Loops --- Emne 3/LoopOppgave/LoopOppgave.sln | 16 ++++++++ .../LoopOppgave/LoopOppgave.csproj | 10 +++++ Emne 3/LoopOppgave/LoopOppgave/Program.cs | 41 +++++++++++++++++++ 3 files changed, 67 insertions(+) create mode 100644 Emne 3/LoopOppgave/LoopOppgave.sln create mode 100644 Emne 3/LoopOppgave/LoopOppgave/LoopOppgave.csproj create mode 100644 Emne 3/LoopOppgave/LoopOppgave/Program.cs diff --git a/Emne 3/LoopOppgave/LoopOppgave.sln b/Emne 3/LoopOppgave/LoopOppgave.sln new file mode 100644 index 0000000..c1118fa --- /dev/null +++ b/Emne 3/LoopOppgave/LoopOppgave.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LoopOppgave", "LoopOppgave\LoopOppgave.csproj", "{55FA6E4E-41B9-4AA6-AD8B-3B8F47DA3D6B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {55FA6E4E-41B9-4AA6-AD8B-3B8F47DA3D6B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {55FA6E4E-41B9-4AA6-AD8B-3B8F47DA3D6B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {55FA6E4E-41B9-4AA6-AD8B-3B8F47DA3D6B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {55FA6E4E-41B9-4AA6-AD8B-3B8F47DA3D6B}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/Emne 3/LoopOppgave/LoopOppgave/LoopOppgave.csproj b/Emne 3/LoopOppgave/LoopOppgave/LoopOppgave.csproj new file mode 100644 index 0000000..2f4fc77 --- /dev/null +++ b/Emne 3/LoopOppgave/LoopOppgave/LoopOppgave.csproj @@ -0,0 +1,10 @@ + + + + Exe + net8.0 + enable + enable + + + diff --git a/Emne 3/LoopOppgave/LoopOppgave/Program.cs b/Emne 3/LoopOppgave/LoopOppgave/Program.cs new file mode 100644 index 0000000..ac9a33c --- /dev/null +++ b/Emne 3/LoopOppgave/LoopOppgave/Program.cs @@ -0,0 +1,41 @@ +using System; + +namespace LoopOppgave +{ + class Program + { + static void Main() + { + Loops(); + } + + static void Loops() + { + // Oppgave 1 + for (int i = 0; i <= 5; i++) + { + Console.WriteLine("Terje er kul"); + } + + // Oppgave 2 + string sentence = "Terje er kul og hei verden fra foreach løkke"; + + foreach (var letter in sentence) + { + Console.WriteLine(letter); + } + + // Oppgave 3 + int number = 0; + while (number < 10) + { + Console.WriteLine($"Runde nummer... {number}"); + number++; + } + } + + } + + +} +