Write a C# Sharp program to check if a given positive number is a multiple of 3 or a multiple of 7

  • برمجة سي شارب
  • برمجة

Write a C# Sharp program to check if a given positive number is a multiple of 3 or a multiple of 7

Sample Output:

True
True
True
False

الأجوبة

using System;
namespace exercises
{
 class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(test(3));
            Console.WriteLine(test(14));
            Console.WriteLine(test(12));
            Console.WriteLine(test(37));
            Console.ReadLine();
        } 
        public static bool test(int n)
        {
            return n % 3 == 0 || n % 7 == 0;
        }
    }
}
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...