WHAT'S NEW?
Loading...

C Program to check for Prime Number

#include 
#include <conio.h>
void main()
{
   int num, c;
 
   printf("Enter a number: ");
   scanf("%d", &num);
 
   if ( n == 2 )
      printf("Given number is Prime");
   else
   {
       for ( c = 2 ; c <= n - 1 ; c++ )
       {
           if ( n % c == 0 )
              break;
       }
       if ( c != n )
          printf("Given Number is not Prime");
       else
          printf("Given number is Prime");
   }
 getch();
}

0 comments:

Post a Comment