prime number:-
#include<stdio.h>
int main()
{
int n,i,count=0;
printf("Enter a number: ");
scanf("%d",&n);
for(i=2;i<=n/2;i++)
{
if(n%i==0)
{
count++;
break;
}
}
if(count==0 && n!= 1)
printf("%d is a prime number",n);
else
printf("%d is not a prime number",n);
return 0;
}
output:-
Enter a number: 7
7 is a prime number
0 comments:
Post a Comment