all about smartphone technologies we discuss here, ranging from specifications and prices, how to fix hp and we provide a lot of applications and games

C# Program to check number is prime or composite

C# Program to check number is prime or composite - welcome to our blog that presents a very complete information is Tech Phone ok now we will discuss the information you are seeking, may I guess if you are looking for information on C# Program to check number is prime or composite if properly come please continue reading until the end, we also provide other information, do not forget to get around:

informations : C# Program to check number is prime or composite
Full link : 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 already been discussed

A few information about the C# Program to check number is prime or composite , hopefully can provide benefits to all of you.

You're reading an article C# Program to check number is prime or composite and this article has a link to https://mastispotgroup.blogspot.com/2013/12/c-program-to-check-number-is-prime-or.html to revel book mark. Hopefully this article could be useful, do not forget to look for information on obtaining the phone tech blog.

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

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

0 komentar:

Posting Komentar