Skip to main content

Program to find given number is divisible by 2 or 3 and divisible 3 and 5

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

Popular posts from this blog

Physical variables and transducer

unit 3 Physical Variables and transducers  Sensor Sensors are electrical devices that have the capability of sensing different physical variables. The sensor may be classified on different bases one of them is a physical quantity. Hence on the basis of a physical quantity or physical vibration involved the sensors are classified as: Resistive sensor  The input being measured is transformed into a change in resistance. examples: potentiometer, resistance thermometer, strain gauge, etc. Inductive sensor The input being measured is transformed into a change in resistance. example LVDT. Capacitive Sensor The input being measured is transformed into a change in capacitance. example: capacitive Displacement sensor. On the basis of power supply required: Active Sensor Active sensors are those which do not require an external power supply.  example: thermo-couple Passive Sensor Passive Sensors are those which require a power supply. example: Potentiometer. Physical variables and ...

WAP to find odd even, prime_composite, and factorial of a number using function

  using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace function { Class Program { static void main(string[] args) { prime_comp(); factorial(); odd_even(); } static public void odd_even() { int n; Console.WriteLine("Input any number."); n= Convert.ToInt32(Console.ReadLine()); if (n%2==0) { Console.WriteLine("The number is even."); } else { Console.WriteLine("The number is odd."); } Console.ReadLine(); } static public void factorial() { int n, i, fact = 1; Consol.WriteLine("Input any number."): n  = Convert.ToInt32(Console.ReadLine()): for(n==0) { Console.WriteLine("The factorial of 0 is 1"); } else{ for(i=1; i<=n; i++) { fact = fact * i; } Console.WriteLine("The factorial of given number is: {0}",fact); } } static public void prime_comp() { int num, flag = 0; Console.WriteLine("Input any number."); num = Convert.ToInt32(Console.ReadLine()); fo...