Please login


Prepinsta Prime

Video courses for company/skill based Preparation

(Check all courses)
Get Prime Video

Prepinsta Prime

Purchase mock tests for company/skill building

(Check all mocks)
Get Prime mock

To check if the number is Prime or not

C Program to check if the given number is prime or not

  • Prime numbers can only be divided evenly by 1 or itself, so these numbers are prime numbers.
  • A few examples of such numbers are 2 , 3 , 5 , 7 , 11 , 13 , …………. and so on.

int main ()
int n, i, a = 0, count = 0;
printf ("Enter the number to check if it is prime or not: ");
scanf ("%d", &n);
a = n / 2;
for (i = 2; i <= a; i++)
if (n % i == 0)
printf ("The given number is not prime");
count = 1;
if (count == 0)
printf ("The given number is prime");
return 0;
Disclaimer-: The questions provided on this page are only model practice questions there is no surety that these questions have been previously asked in any company placement papers, these questions here only have the sole purpose to make you practice coding questions