Write a program to check whether a number is prime or not.
#include<stdio.h>
int main(){
int n, i;
printf("Enter number : ");
scanf("%d",&n);
for(i=2;i<n/2;i++)
{
if(n%i == 0)
{
break;
}
}
if(i == n)
{
printf("\n %d is Prime number.",n);
}
else
{
printf("\n %d is not Prime number.",n);
}
}
0 Comments