Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lernen Herausforderung: If-Bedingung | Kontrollstrukturen
C# Grundlagen
course content

Kursinhalt

C# Grundlagen

C# Grundlagen

1. Erste Schritte
2. Umgang mit Datentypen
3. Kontrollstrukturen
4. Schleifen
5. Arrays
6. Methoden

book
Herausforderung: If-Bedingung

Schreiben Sie eine if-Bedingung, die überprüft, ob die Variable x im Bereich von 40 bis 70 liegt (einschließlich 40 und 70). Verwenden Sie die <= Operatoren für Vergleich. Wenn die Bedingung wahr ist, sollte sie "In Range" ausgeben.

cs

main

copy
12345678910111213141516
using System; namespace ConsoleApp { class Program { static void Main(string[] args) { int x = 55; // Write code below this line // Write code above this line } } }

Die Syntax einer if-Bedingung ist: if(condition) { /* code to execute */ }

cs

main

copy
1234567891011121314151617181920
using System; namespace ConsoleApp { class Program { static void Main(string[] args) { int x = 55; // Write code below this line if (40 <= x && x <= 70) { Console.WriteLine("In Range"); } // Write code above this line } } }

War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 3. Kapitel 6
We're sorry to hear that something went wrong. What happened?
some-alt