Gadget Corner, Huawei stock ROMs, Miracle Box, How To Install, Clone Firmware, Android Latest Version, HTC Firmware Flash File, and more information about gadgets for you

C# Program to check number is prime or composite

C# Program to check number is prime or composite - Welcome to the blog Gadget Corner we provide a lot of latest gadget information that must be very loss for you to miss, now we will discuss first about C# Program to check number is prime or composite we have collected a lot of information to make this article complete for you, Ok please read::

You can also see our article on:


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();

}



Articles about C# Program to check number is prime or composite finished discussed

We think it is enough information about C# Program to check number is prime or composite , hopefully the information we give can give benefit for you,

If you feel the information C# Program to check number is prime or composite that we provide can provide benefits for others please share with link https://darellsfinancialcorner.blogspot.com/2013/12/c-program-to-check-number-is-prime-or.html thank you for visiting our blog page and do not forget to visit other

Share on Facebook
Share on Twitter
Share on Google+

Related : C# Program to check number is prime or composite

0 komentar:

Posting Komentar