언어/[C#]
[C#] 논리연산자 && (and), || (or)
조랩
2023. 3. 1. 00:51
using System;
namespace MyFirstProgram
{
internal class Program
{
static void Main(string[] args) // main method
{
// 논리연산자
// && and, || or
Console.WriteLine("What's the temperature outside: (C)");
double temp = Convert.ToDouble(Console.ReadLine());
if (temp >= 10 && temp <= 25) // 두 조건 모두 충족해야 true
{
Console.WriteLine("It's warm outside!");
}
else if (temp <= -50 || temp >= 50) // 둘 중 하나라도 충족하면 true
{
Console.WriteLine("Do not go outside!");
}
}
}
}
728x90