C Programming
Computer Programming

Program in c to Check Whether a Number is Prime or Not



Write a Program in c to Check Whether a Number is Prime or Not

\* C Program to to Check Whether a Number is Prime or Not *\

# include < stdio.h >
int   main( )
{

int   num, f, temp, i  ;
printf(" Enter the Number : ") ;
scanf("%d ", & num) ;
f = 0 ;
for (   i = 2 ;  i < num ;  i++ );
{

if (   num % i == 0 )
f = f + 1 ;

}
if (   f > 0 )
printf(" \n Entered Number is not a Prime !! ") ;
else
printf(" \n Entered Number is Prime !! ") ;
return ( 0 ) ;

}

Output of Program :

Output of Program in C to Check Whether a Number is Prime or Not