C Program To Determine if a number is prime or not

in Steem Sri Lanka2 days ago

Image cover

Dear friends, today I am sharing this post with you through this video and in this video I have shared with you a C program to determine whether a number is prime or not. I have run this program online and shown the results by inputting it several times. You will understand it very easily when you see it. And if anyone knows anything, then definitely let me know through the comments. I am giving the program below this article. You can copy it from here and go online and run it exactly as I have shown you, and you can show the results by inputting it.

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

IPFS Video

Posted with Speem

Sort:  

¡Hi friend!

#play

Image
Video reviewed by speem videos watcher @luisito01

1000091620.png

Coin Marketplace

STEEM 0.06
TRX 0.31
JST 0.061
BTC 67744.77
ETH 2091.48
USDT 1.00
SBD 0.50