c# 짝수&홀수 판별 프로그램 [콘솔]

Posted by 슈퍼너드 리보
2020. 7. 9. 14:43 프로그래밍/C#
반응형

시간이 생겨 c#을 이용해 짝수 홀수 판별 프로그램을 만들어봤습니다.

소스코드

using System;

namespace even_odd
{
    class even_odd
    {
        static void Main(string[] args)
        {
            int i;
            Console.Write("숫자를 입력하고 엔터키를 눌르세요 : ");
            i = int.Parse(Console.ReadLine());
            if (i % 2 == 0)
            {
                Console.Write("짝수");
                Console.Read();
            }
            else
            {
                Console.Write("홀수");
                Console.Read();
            }
        }
    }

}

사용된 개념

입출력문, 조건문, 연산자

알고리즘

짝수는 나머지가 0, 홀수는 나머지가 1이다에 착안

반응형