- 1

# Who can help me I'm beginning

2nd Nov 2022, 1:20 PM
Mohamed Amandar + 2
Thanks
2nd Nov 2022, 3:08 PM
Mohamed Amandar + 3
Please DO NOT link code that is not related to your question. What have you tried so far? Can you please link your code so we can have a look at it? You can find example codes only. https://www.programiz.com/c-programming/examples/prime-number
2nd Nov 2022, 1:26 PM
Lisa + 2
Yes, that's what you have already told us. Have a look at the 2nd paragraph: I asked some questions there.
2nd Nov 2022, 1:40 PM
Lisa 0
I'm new here
2nd Nov 2022, 1:38 PM
Mohamed Amandar 0
#include <stdio.h> #include <math.h> int main() { int n,i; printf("enter any number"); scanf("%d/2",&n); for(i=2;i<=1;i++) { printf("not prime number: "); } return 0; }
2nd Nov 2022, 1:44 PM
Mohamed Amandar 0
#include <stdio.h> int isPrime (int n) ; int main() { int n; scanf("%d/2",&n); if(isPrime(n)==1) printf("prime number"); else printf("Not Prime number"); return 0; } int isPrime(int n){ for(int i=3;i<n;i++) if(n%2==0)return 0; return (n>1?1:0); }
2nd Nov 2022, 3:02 PM
I am offline 0
#include <stdio.h> int main() { int n, i, flag = 0; printf("Enter a positive integer: "); scanf("%d", &n); // 0 and 1 are not prime numbers // change flag to 1 for non-prime number if (n == 0 || n == 1) flag = 1; for (i = 2; i <= n / 2; ++i) { // if n is divisible by i, then n is not prime // change flag to 1 for non-prime number if (n % i == 0) { flag = 1; break; } } // flag is 0 for prime numbers if (flag == 0) printf("%d is a prime number.", n); else printf("%d is not a prime number.", n); return 0; }
4th Nov 2022, 8:35 AM
Pooja Patel 