0

this is a simple code to test whether a number is prime or not...i dont know y it is taking this much time to execute...can ne1 tell where m mistaking??

heres my code

```
#include<stdio.h>
#include<math.h>
int main()
{
int a,n,prime,l=2;
printf("Please enter a positive integer.\n");
printf("To end the program enter a negetive integer.\n");
while(l>1){
scanf("%d",&n);
prime=1;
if(n<=1) printf("The number is not prime.\n");
else if(n==2) printf("The number is prime.\n");
else{
for(a=2;a<=(int)sqrt(n);a++){
if(!(n%a)) prime=0;
}
if(prime==0) printf("The number is not prime.\n");
else printf("The number is prime.\n");
}
if(n<0){
break;
}
printf("Please enter a positive integer.\n");
printf("To end the program enter a negetive integer.\n");
}
return 0;
}
```

*Edited 5 Years Ago by aamira_s*: spelling mistake