Run Code  | API  | Code Wall  | Misc  | Feedback  | Login  | Theme  | Privacy  | Patreon 

EX8 Loop_For_While

//Rextester.Program.Main is the entry point for your code. Don't change it.
//Microsoft (R) Visual C# Compiler version 2.9.0.63208 (958f2354)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace Rextester
{
    public class Program
    {
        public static void Main(string[] args)
        {
           for (int i = 1; i <= 5; i++) 
              {
                Console.WriteLine(i+" Saisawas");
              } 
           Console.WriteLine();
           for (int i = 5; i >= 1; i--) 
              {
                Console.WriteLine(i+" Thongsri");
              }
              
          Console.WriteLine();
      //คำสั่ง  While
           int j = 10;
           while (j >=1) 
              {
                Console.WriteLine(j+" Saisawas");
                j=j-3;
              }
           Console.WriteLine();   
           int k = 1;
           while (k <=10) 
              {
                Console.WriteLine(k+" Thongsri");
                k=k+3;
              }   
        }
    }
}
 run  | edit  | history  | help 0