/*C Program To Check Whether The Given Number Is Prime Number Or Not*/ #include <stdio.h> #include <stdlib.h> int main() { int num,i,count=0; printf("Enter the value:\n"); scanf("%d",&num); for(i=2;i<=num/2;i++){ if(num%i==0){ count++; break; } } if(count==0 && num!= 1) printf("%d is a prime number",num); else printf("%d is not a prime number",num); return 0; }
Enter the value: 2 2 is a prime number
No comments:
Post a Comment