Keywords: prime c program, c program for prime numbers, c program to find prime numbers, a program for the prime number in c, c program for a prime number. In this example, you will learn how to check whether the input number is a Prime number or not. See the below example:

C

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
#include<stdio.h> int main() { int num, i, count = 0; printf("Enter a number:"); scanf("%d", &num); for (i = 2; i <= num / 2; i++) { if (num % i == 0) { count++; break; } } if (count == 0) printf("%d is a prime number", num); else printf("%d is not a prime number", num); return 0; } |

If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.

- C program to implement bit flipping
- C program to implement hashing
- C program to implement SJF algorithm
- stdio.h library functions list in c
- conio.h functions list in c
- C program remove spaces, blanks from a string
- How to write c program code for pow
- Program to delete n characters from a given position in a given string
- C program to solve the Number of stopping station problem
- C implementation of inserting a new node to a link list

Article Tags: c program for prime number, c program for prime numbers, c program to find prime numbers, c tutorials, prime number program in c, write a program to find prime numbers from 1 100