Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: if Condition | Control Structures
C# Basics

bookChallenge: if Condition

Write an if-condition which checks if the variable x is in the range of 40 to 70 (including 40 and 70). Use the <= operators for comparison. If the condition is true, it should output "In Range".

main.cs

main.cs

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 } } }

The syntax of an if-condition is: if(condition) { /* code to execute */ }

main.cs

main.cs

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 } } }

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 3. Kapittel 6

Spør AI

expand

Spør AI

ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

Awesome!

Completion rate improved to 1.59

bookChallenge: if Condition

Sveip for å vise menyen

Write an if-condition which checks if the variable x is in the range of 40 to 70 (including 40 and 70). Use the <= operators for comparison. If the condition is true, it should output "In Range".

main.cs

main.cs

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 } } }

The syntax of an if-condition is: if(condition) { /* code to execute */ }

main.cs

main.cs

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 } } }

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 3. Kapittel 6
some-alt