All Type Coding

Search Here

How do I check that the number is divisible by 5 or not using c#.?

using System;

class abc
{
    int a;
    public void div()
    {
        Console.WriteLine("Enter The no to check that it is divisible by 5 or not");
        a = Convert.ToInt32(Console.ReadLine());
        if (a % 5 == 0)
        {
            Console.WriteLine("Divisibe by 5");
        }
        else
        {
            Console.WriteLine("Not divisible by 5");
        }
        Console.ReadKey();
    }
}
class div1
{
    public static void Main(string[] args)
    {
        abc a = new abc();
        a.div();
    }

}
Output:




No comments :

Post a Comment