Notice
Recent Posts
Recent Comments
Link
«   2025/10   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Archives
Today
Total
관리 메뉴

행복한 개구리

C# 0309 ★for, ★while, do while, foreach 본문

C#/수업내용

C# 0309 ★for, ★while, do while, foreach

HappyFrog 2021. 3. 9. 16:07
 int count = 0;
            for (int i = 0; i < 5; i++)                
            {
                Console.WriteLine("줄넘기를 {0}회 했습니다.", i+1);
                count++;

            }
            Console.WriteLine("총 줄넘기한 횟수 : {0}", count);


            //줄넘기를 1회 했습니다.
            //줄넘기를 2회 했습니다.
            //줄넘기를 3회 했습니다.
            //줄넘기를 4회 했습니다.
            //줄넘기를 5회 했습니다.
            //**********************
            //총 줄넘기한 횟수 : 5회
            int n = 0;
            while (n<5)
            {
                Console.WriteLine(n);
                n++;
                
            }
            Console.WriteLine("{0}회 실행되었습니다.", n);
            
            =======================================================
            using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Homework000
{
    class Program
    {
       
     
       
        static void Main(string[] args)
        {
            int n = 0;
            do
            {
                Console.WriteLine(n);
                n++;
            } while (n < 5);

            

        }

    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Homework000
{
    class Program
    {
       
     
       
        static void Main(string[] args)
        {
            string[] names = new string[3] { "홍길동", "임꺽정", "장길산" };
            foreach (string name in names)
            {
                Console.WriteLine(name);
            }
        }

    }
}

'C# > 수업내용' 카테고리의 다른 글

C# 0309 커멘드센터 SCV  (0) 2021.03.09
C# 0309 ★break, ★continue  (0) 2021.03.09
C# 0309 ★if와 ★switch  (0) 2021.03.09
0309 C# 강화 성공, 실패  (0) 2021.03.09
0309 C# Random 크리티컬 || &&  (0) 2021.03.09