Whether a given number is prime or not
#include<stdio.h>
void main()
{
int n,i=2;
printf("\nEnter a number \n");
scanf("%d",&n);
for(i=2;i<=n-1;i++)
{
if(n%i==0)
{
printf("%d isn't prime...!\n",n);
break;
}
}
if(i==n)
printf("%d is prime...!\n",n);
}
Output
Video Class : Prastheena Learning Class
Comments