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

_21_for_question

by FourthWay 2023. 4. 20.
728x90
반응형

[Question]

for문을 사용해서 해결한다

나무를 20번 찍습니다

3번에 1번씩 '쩍'을 출력합니다

20번을 모두 완료하면

'나무가 쿵'을 출력합니다.

 

using System;

namespace _21_for-question
{
 internal class Program
 {
  static void Main(string[] args)
  {
   for(int i=1; i<=20;++i)
   {
    Console.WriteLine("나무를" + i + "번 찍습니다");
    if(i % 3 = 0)
    Console.WriteLine("쩍~");
   }
   Console.WriteLine("나무가 쿵!");
  }
 }
}

728x90
반응형

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

_24_function  (1) 2023.04.28
_22_for_Question  (0) 2023.04.20
_19_for  (1) 2023.04.19
_18_do_while  (0) 2023.04.16
_17_while  (0) 2023.04.16