Check Whether a number is Prime or not


/*
 *      
 *      Copyright 2011 techstream.org < techstream.org[at]gmail.com >
 *      
 *      This program is free software; you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation; either version 2 of the License, or
 *      (at your option) any later version.
 *      
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *      
 */

#include
#include      // to use clrscr and getch
void main()
{
    clrscr();
    int num,n,a;
    cout<<"enter number:";
    cin>>num;
        for(n=2;n<=(num/2);n++)
        {
        if (num%n==0)
        {
        a=1;
        break;
            }
        else
         a=0;
           }
           if(a==1)
           cout<<"nIt is not a prime number";
           else
           cout<<"nIt is prime number";
        
    getch();
}