write a program to find out the given number is prime or not
Answers
Answered by
1
#include <stdio.h>
int main()
{
int n, i, flag = 0;
printf("Enter a positive integer: ");
scanf("%d", &n);
for(i = 2; i <= n/2; ++i)
{
// condition for nonprime number
if(n%i == 0)
{
flag = 1;
break;
}
}
Answered by
1
Answer:
int c=0,n;
(where n is the number)
for(int i=1;i<=n;i++)
{
if(n%i==0)
,{
c++;
}
}
if(c==2)
System.out.println(Prime number)
else
Sopln(not a prime number)
Similar questions