Utmaning: If-Villkor
Skriv en if-sats som kontrollerar om variabeln x ligger inom intervallet 40 till 70 (inklusive 40 och 70). Använd operatorerna <= för jämförelse. Om villkoret är sant ska det skriva ut "In Range".
main.cs
12345678910111213141516using System; namespace ConsoleApp { class Program { static void Main(string[] args) { int x = 55; // Write code below this line // Write code above this line } } }
Syntaxen för en if-sats är:
if(condition) { /* code to execute */ }
main.cs
1234567891011121314151617181920using 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 } } }
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 3. Kapitel 6
Fråga AI
Fråga AI
Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal
Awesome!
Completion rate improved to 1.59
Utmaning: If-Villkor
Svep för att visa menyn
Skriv en if-sats som kontrollerar om variabeln x ligger inom intervallet 40 till 70 (inklusive 40 och 70). Använd operatorerna <= för jämförelse. Om villkoret är sant ska det skriva ut "In Range".
main.cs
12345678910111213141516using System; namespace ConsoleApp { class Program { static void Main(string[] args) { int x = 55; // Write code below this line // Write code above this line } } }
Syntaxen för en if-sats är:
if(condition) { /* code to execute */ }
main.cs
1234567891011121314151617181920using 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 } } }
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 3. Kapitel 6