Check whether the given number is prime or not using C

/*WAP to check whether the given number is prime or not*/
#include<stdio.h>
void main()
{
int n,i;
clrscr();
printf("Enter A Integer Number-\n");
scanf("%d",&n);
for(i=2;i<n;i++)
{
if(n%i==0)
 {
 printf("The Number %d is Not a Prime Number\n",n);
 break;
 }
 }
 if(i==n)
 printf("The Number %d is Prime Number\n",n);
getch();
}

Output

Enter A Integer Number-
5
The Number 5 is Prime Number

Download Program

Download