C Program To Determine if a number is prime or not
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;
}
Posted with Speem

¡Hi friend!
#play
Video reviewed by speem videos watcher @luisito01