C Program To Know The Number is prime or not

#include<stdio.h>
#include<conio.h>
void main()
{
int i,n,count;
i=1;
count=0;
clrscr();
printf("enter the value of n");
scanf("%d",&n);
while(i<=n)
{
if(n%i==0)
{
count=count+1;
i=i+1;
}
else
i=i+1;
}
if(count==2)
{
printf("its a prime:%d",n);
}
else
printf("its not a prime number:%d",n);
getch();
}
Bhanu Namikaze

Bhanu Namikaze is an Ethical Hacker, Web Developer, Student and Mechanical Engineer. He Enjoys writing articles, Blogging, Solving Errors and Social Networking. Feel Free to let me know any of your concerns about hacking or let me know if you need any more methods on hacking anything. Enjoy Learning

No comments:

Post a Comment