Tuesday, December 24, 2013

C# Program to check number is prime or composite

C# Program to check number is prime or composite - welcome to the blog Gadget Warrior, on this occasion we will discuss the information titled C# Program to check number is prime or composite as you are looking for, we have collect a lot of data to make this article so that you are satisfied with the information we convey, well please continue reading:

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,

You can also see our article on:


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 C# Program to check number is prime or composite finished we discussed

A few of our information about the C# Program to check number is prime or composite , I hope that we submit article easy to understand

You've finished reading an 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 http://mallcopwarrior.blogspot.com/2013/12/c-program-to-check-number-is-prime-or.html Hopefully discussion articles on could provide more knowledge about gadgets.

Tag : , , ,
Share on Facebook
Share on Twitter
Share on Google+

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

0 comments:

Post a Comment