Computer Science, asked by pandaranjit25, 1 year ago

write a c programe to find prime number

Answers

Answered by khanujarashmit
2
A prime number means a positive integer which is divisible only by 1 and itself. For example: 2, 3, 5, 7, 11, 13 Program to Check Prime Number #include int main() { int num, i, flag = 0; printf("Enter a positive integer number: "); scanf("%d",&num); for(i=2; i<=num/2; ++i) { // condition for nonprime number if(num%i==0) { flag=1; break; } } if (flag==0) printf("%d is a prime number.",num); else printf("%d is not a prime number.",num); return 0; }
Similar questions