#include<stdio.h>
int isPrime(int);
int main(){
int num,prime;
printf("Enter a positive number: ");
scanf("%d",&num);
prime = isPrime(num);
if(prime==1)
printf("%d is a prime number",num);
else
printf("%d is not a prime number",num);
return 0;
}
int isPrime(int num){
int i=2;
while(i<=num/2){
if(num%i==0)
return 0;
else
i++;
}
return 1;
}
int isPrime(int);
int main(){
int num,prime;
printf("Enter a positive number: ");
scanf("%d",&num);
prime = isPrime(num);
if(prime==1)
printf("%d is a prime number",num);
else
printf("%d is not a prime number",num);
return 0;
}
int isPrime(int num){
int i=2;
while(i<=num/2){
if(num%i==0)
return 0;
else
i++;
}
return 1;
}
ok i have note down this in my program.
ReplyDeletethat is good.
good explanation
ReplyDeletehttp://ccppcoding.blogspot.in/
Bro your doing an awesome jobs ..
ReplyDeleteFor more Tricky C programs Visit ►► Lightning Code
Great post. Very useful information for beginners. I really thankful for this post. c programming classes in pune
ReplyDelete