- 4
Program to check given number is prime or not
I don't know how to solve
7 Respostas
+ 4
Hint 1. You need to count the factors of a number if the factors of a number is only ( 1 and the number itself) then it is prime number
Hint 2. For finding factor run a loop and check num%2 == 0
Try this and then show your attempt
+ 3
Manash Saikia Even i
+ 2
Krish Ok man
+ 2
sanyami sukhdeve at least write something and attach it here so that we can improve your attempt
+ 1
Krish I deleted the answer
+ 1
#include <stdio.h>
int main()
{
int n,i, flag;
printf("enter n =");
scanf("%d",&n);
for(i=2; i<n;i++)
{
if(n%2==0)
{
flag=1;
break;
}
}
if (flag==1)
{
printf("not a prime ");
}
else
{
printf("\nprime no. ");
}
return 0;
}
Hope it will be helpful to you 🙂
0
Okay