Write a program to check weather given number is prime or not

4/21/2013 05:01:00 pm Unknown 0 Comments



#include <stdio.h>
#include <conio.h>
int main()
{
       int a, b, counter=0, num;
       printf("Enter number: ");
       scanf("%d", &num);
                for(b=2; b<num; b++)
                {
                         if ((num%b)==0)
                         {
                            counter++;
                         }  
                }
                if(counter==0 && num!= 1)
                {
                              printf("%d is a prime number.", num);          
                }
                else
                printf("%d is not a prime number.", num);
       getch();
}