1.Program to find the given number is divisible by 2 or 3
using System;
using System.Collections.Generic;using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace div_2or_3
{
Class Program
{
static void main(string[] args)
{
int a;
Console.WriteLine("Please enter any number:");
a = Convert.ToInt32(Console.ReadLine());
if (a % 2 == 0 || a% 3 == 0)
{
Console.WriteLine("The number is divisle by 2 or 3:");
}
else {
Console.WriteLine("The number is neither divisible by 2 or 3 . " ) ;
}
Console.ReadLine();
}
}
}
OUTPUT:
Please enter any number: 8
The number is divisible by 2 or 3.
2.Program to find the given number is divisible by 3 and 5:
using System;
using System.Collections.Generic;using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace div_3and_5
{
Class Program
{
static void main(string[] args)
{
int a;
Console.WriteLine("please enter any number.");
a = Convert.ToInt32(Console.ReadLine());
if(a%3 == 0 && a%5 == 0)
{
Console.WriteLine("The number is divisible by 3 and 5.");
}
else
{
Console.WriteLine("The number is not divisible by 3 and 5.");
}
Console.ReadLine();
}
}
}
OUTPUT:
Please enter any number: 50
The number is not divisible by 3 and 5.
Comments
Post a Comment