- 4

Program to check given number is prime or not

I don't know how to solve

27th Dec 2020, 8:26 AM
sanyami sukhdeve
sanyami sukhdeve - avatar
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
27th Dec 2020, 8:30 AM
Krish
Krish - avatar
+ 3
27th Dec 2020, 8:34 AM
Krish
Krish - avatar
+ 2
Krish Ok man
27th Dec 2020, 8:33 AM
Manash Saikia [ 45% Active ]
Manash Saikia [ 45% Active ] - avatar
+ 2
sanyami sukhdeve at least write something and attach it here so that we can improve your attempt
27th Dec 2020, 8:37 AM
Krish
Krish - avatar
+ 1
Krish I deleted the answer
27th Dec 2020, 8:33 AM
Manash Saikia [ 45% Active ]
Manash Saikia [ 45% Active ] - avatar
+ 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 🙂
27th Dec 2020, 3:14 PM
KRITI
KRITI - avatar
0
Okay
27th Dec 2020, 8:38 AM
sanyami sukhdeve
sanyami sukhdeve - avatar