This is about : C# Program to check number is prime or composite
And this article : C# Program to check number is prime or composite
Article Csharp, Article programming, Article programs,
C# Program to check number is prime or composite
C# Program to check entered number is prime or composite
Program Statement:
Write a program that takes an integer as an input from user and prints if it is a prime or composite number.
Solution:
static void Main(string[] args)
{
int num, i;
Console.WriteLine("Enter the number to check number is prime or composite");
num=Convert.ToInt32(Console.ReadLine());
i = 2;
while (i <= num - 1)
{
if (num % i == 0)
{
Console.WriteLine("composite number: "+num);
break;
}
i++;
}
if (i == num)
Console.WriteLine("prime number: " + num);
Console.ReadLine();
}
Information C# Program to check number is prime or composite has been completed we present
A few of our information about the C# Program to check number is prime or composite , we hope you benefit from this article
You have just read the article C# Program to check number is prime or composite and many articles about gadget in our blog this, please read it. and url link of this article is https://howtomonetizeeverything.blogspot.com/2013/12/c-program-to-check-number-is-prime-or.html Hopefully discussion articles on provide more knowledge about the world of tech gadgets.
Tag : Csharp, programming, programs,
0 Response to "C# Program to check number is prime or composite "
Post a Comment