Desafio de if-condition
Escreva uma condição if que verifica se a variável x
está no intervalo de 40 a 70 (incluindo 40 e 70). Use os operadores <=
para comparação. Se a condição for verdadeira, deve exibir "In Range".
main.cs
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
using System;
namespace ConsoleApp
{
class Program
{
static void Main(string[] args)
{
int x = 55;
// Write code below this line
// Write code above this line
}
}
}
12345678910111213141516using System; namespace ConsoleApp { class Program { static void Main(string[] args) { int x = 55; // Write code below this line // Write code above this line } } }
A sintaxe de uma condição if é:
if(condition) { /* código a executar */ }
main.cs
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
}
}
}
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 } } }
Tudo estava claro?
Obrigado pelo seu feedback!
Seção 3. Capítulo 6
Pergunte à IA
Pergunte à IA
Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo