0
Find a no. Is prime or not. Pls fix this code
Prime no. Finding in C language https://code.sololearn.com/ch15QE4iAE54/?ref=app
1 Resposta
+ 17
#include <stdio.h>
#include <math.h>
main() {
int num,i,k;
printf("Enter a number :");
scanf("%d",&num);
i = 2;k=sqrt (num);
while( i<=k){
if(num%i==0&&num!=2){
printf("%d is not a prime number ",num);
printf("\n Number % divisible by %d ",num,i);
break;
}
i++;
}
{ if(i==k+1)
printf ("\n %d is a prime number",num);
}
}
//have a look at loop , increment of variable [there was main error] + some error in if() statement[logical error] + some error in wrong placed brackets {}
//fixed☺