By GokiSoft.com|
15:02 18/05/2020|
C Sharp
[Share Code] Hướng dẫn tìm hiểu vòng lặp Loop - For - While - Do While - Lập Trình C# - Lập Trình C Sharp
[Share Code] Hướng dẫn tìm hiểu vòng lặp Loop - For - While - Do While - Lập Trình C# - Lập Trình C Sharp
#Program.cs
using System;
namespace Lession3
{
class Program
{
static void Main(string[] args)
{
//loopWhile();
//loopDoWhile();
loopFor();
}
static void loopFor() {
int num;
for (num = 0; num <= 11; num++) {
if(num % 2 == 0) {
Console.WriteLine("num = {0}", num);
}
}
}
static void loopDoWhile() {
int num = 0;
//TH => lap vo han
do
{
if (num % 2 == 0)
{
Console.WriteLine("num = {0}", num);
}
num++;
} while (num <= 11);
Console.WriteLine("Stop");
}
static void loopWhile() {
int num = 0;
//TH => lap vo han
while(num <= 11) {
if(num % 2 == 0) {
Console.WriteLine("num = {0}", num);
}
num++;
}
Console.WriteLine("Stop");
}
}
}
Tags:
Phản hồi từ học viên
5
(Dựa trên đánh giá ngày hôm nay)