C# Program to check number is prime or composite

C# Program to check number is prime or composite - welcome to our blog Techno Live, now we will discuss information about the C# Program to check number is prime or composite , our admins on this blog has been around to collect information you are looking for so that we usakan to display complete information for you, and in this blog, you can also search for other information, ok please continue reading may be easily understood:

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 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 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 you can exploit carefully

No've You've finished reading an article on C# Program to check number is prime or composite and many articles about modern home in our blog this, please read it. and url link of this article is https://liveeconcerts.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 : , , ,

Related Posts :

0 Response to "C# Program to check number is prime or composite "

Post a Comment