Site hosted by Angelfire.com: Build your free website today!

This program is short and sweet. All you have to do is enter a number and it will tell you if it is a prime or not a prime. Works with pretty high numbers.



Want to Download the Program?


This is the Code for The Program.


#include <stdio.h> #include "iostream.h" bool prime(long num, bool & check); int main(void) { long num; bool check=false; while(100){ cout<<"Enter in a positive integer "; cin>>num; cout<<endl; prime(num,check); if(check==false) cout<<"Isn't a Prime Number\n\n\n"; else cout<<"A Prime Number\n\n\n"; } } bool prime(long num, bool & check) { for(int x=2;x<(int(sqrt(num)))+1;x++) { if (num%x==0) { check=false; break; } if (num%x!=0) check=true; } return check; }