본문 바로가기
프로그래머/코딩(C#)

_04_Operator / 비교연산

by FourthWay 2023. 3. 29.
728x90
반응형
using System;

namespace _04_Operator
{
 internal calss program
 {
  static void Main(string[] args)
  {
   bool bResult;
   int num0 = 0, num1 = 0;
   
   Console.WriteLine("대소 비교 연산을 합니다.");
   Console.WriteLine("첫 번째 숫자를 입력하세요");
   string strNum0 = Console.ReadLine();
   num0 = Int32.Parse(strNum0);
   
   Console.WriteLine("두 번째 연산을 입력하세요");
   string strNum1 = Console.ReadLine();
   num1 = Int32.Parse(strNum1);
   
   //비교연산자의 결과는 True/False 중 1가지 입니다.
   bResult = num0>num1;
   
   //조건에 따라 분기를 할 때에는 이런 대소비교를 하는 연산자를 많이 쓴다.
   //이 둘 중 하나로 도출된 겨로가 값이 bResult에 저장된다.
   //이 변수를 선언할 때에는 bool이라고 해야한다.
   Console.WriteLine(num0 + "은" + num1 + "보다 크다는 사실은" + bResult + "입니다.");
  }
 }
}

728x90
반응형

'프로그래머 > 코딩(C#)' 카테고리의 다른 글

_06_if else / if문  (2) 2023.03.30
_05_if / if문  (0) 2023.03.30
_03_Operator / 연산자  (2) 2023.03.29
_02_Integer  (6) 2023.03.28
_01_Variable  (4) 2023.03.28