# Prime number program

#### Prime number program in c

``` #include<stdio.h> #include<conio.h> void CheckPrimeNumber(int number); void main() { int input; printf("Enter your number \n"); scanf("%d",&input); CheckPrimeNumber(input); getch(); } void CheckPrimeNumber(int number) { int count=0; for(int i=2;i<number;i++) { if(number%i==0) { count=1; break; } } if(count==0) { printf("Yes, %d is a prime number",number); } else { printf("No, %d is not a prime number",number); } } ```

#### Output

```Enter your number 29 Yes, 29 is a prime number ```

#### Prime number program in c++

``` #include<iostream> #include<conio.h> using namespace std; class PrimeNumber { public: int CheckPrimeNumber(int number) { int count=0; for(int i=2;i<number;i++) { if(number%i==0) { count=1; break; } } if(count==0) { return number; } else { return 0; } } }; void main() { int input; cout<<"Enter your number \n"; cin>>input; PrimeNumber primeNumber; int s = primeNumber.CheckPrimeNumber(input); if(s>0) { cout<<"Yes, "<<input<<" is a prime number"; } else { cout<<"No, "<<input<<" is not a prime number"; } getch(); } ```

#### Output

```Enter your number 37 Yes, 37 is a prime number ```

#### Prime number program in c#

``` using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace PrimeNumberProject { class PrimeNumber { public int CheckPrimeNumber(int number) { int count = 0; for (int i = 2; i < number; i++) { if (number % i == 0) { count = 1; break; } } if (count == 0) { return number; } else { return 0; } } static void Main(string[] args) { PrimeNumber pn = new PrimeNumber(); Console.WriteLine("Enter your number"); int input = Convert.ToInt32(Console.ReadLine()); int s = pn.CheckPrimeNumber(input); if (s > 0) { Console.Write("Yes, " + input + " is a prime number"); } else { Console.Write("No, " + input + " is not a prime number"); } Console.ReadLine(); } } } ```

#### Output

```Enter your number 43 Yes, 43 is a prime number ```

#### Prime number program in java

``` import java.util.*; class PrimeNumber { public int CheckPrimeNumber(int number) { int count = 0; for (int i = 2; i < number; i++) { if (number % i == 0) { count = 1; break; } } if (count == 0) { return number; } else { return 0; } } } class examples { public static void main(String[] args) { PrimeNumber primeNumber=new PrimeNumber(); Scanner obj= new Scanner(System.in); System.out.println("Enter your number"); int input=obj.nextInt(); int s=primeNumber.CheckPrimeNumber(input); if(s>0) { System.out.println("Yes, "+input+" is a prime number"); } else { System.out.println("No, "+input+" is not a prime number"); } } } ```

#### Output

```Enter your number 53 Yes, 53 is a prime number ```

### Write a comment

Name Email Message