The following code shows how to Find Whether a Number is Prime or Not in C.

// Find Whether a Number is Prime or Not

#include <stdio.h>

int main()
{
    int num, second, i, prime=1;
    printf("Enter a Number: ");
    scanf("%d", &num);
    

    for(i=2;i<=num/2;i++)
    {
        if(num%i==0)
        {
            prime=0;
            break;
        }
    }
    if(prime)
        printf("%d is a prime number!", num);
    else
        printf("%d is not a prime number!", num);
    return 0;
}

Output

Enter a Number: 59
59 is a prime number!

Enter a Number: 689
689 is not a prime number!


Further Reading

50+ C Programming Interview Questions and Answers

C Program to Find Factorial of a Number