Jinson Jacob -3 Newbie Poster
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int num=0;
int c=0;
cout<<"               Prime OR Not"<<endl<<endl;
cout<<"Enter a number you want to test for prime number: ";
cin>>num;
for(int i=2;i<num;i++)
{
if(num%i==0)
{
     c=0;
     break;
}
else
{
c=1;
}
}
if(num==2||c==1)
{
cout<<"The number is Prime  ";
}
else
{
cout<<"The number is not Prime ";
}
getch();
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.