Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> C#

วิธีหาและแสดงตารางสูตรคูณใน C#

ใช้ลูป while และจัดรูปแบบ Output:

while (a <= 10) { }

จัดรูปแบบ:

Console.WriteLine(" {0} x {1} = {2} \n ", n, a, n * a);

ตัวอย่าง

using System;
public class Demo {
    public static void Main() {
        int n = 4, a = 1;
        while (a <= 10) {
            Console.WriteLine(" {0} x {1} = {2} \n ", n, a, n * a);
            a++;
        }
    }
}