prime number using square root -asr
prime number c program using square root function -asr
#include <stdio.h>#include <conio.h>
#include <math.h>
void main(){
int i,n,r,a=0;
clrscr();
printf("Enter number\n");
scanf("%d",&n);
if(n%2==0||n%3==0||n%5==0||n%7==0)
{
r=1;
goto check;
}
for(i=11,a=1;i<=(int)sqrt(n);i=i+2,a++)
{
if(n%i==0)
{
r=1;
break;
}
}
check:
printf("Loop runned %d times\n",a);
if(r==1)
printf("number is not prime");
else
printf("number is prime");
getch();
}
Comments
Post a Comment