Prime Numbers Program(C++)


Finding Prime Number in C++ programming Language?

#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int Num[10];
for(int i=0; i<10;i++)
{
line:
int count=0;
cout<<"Enter The Num.    ..";cin>>Num[i];
for(int a=1; a<=Num[i]; a++)
{
if(Num[i]==1)
{
cout<<"Prime Number......"<<endl;
goto line;
}
if(Num[i]%a==0)
{
count++;
}
}
if(count==2)
{
cout<<"Prime Number....."<<endl<<endl;
}
else
{
cout<<"Not A Prime Number...."<<endl<<endl;
}

}
getch();
}

Output Result


Comments

Popular posts from this blog

Even/Odd Number Checking Code in CPP

Calculating Name and Marks in Cpp

Triangle of Characters(CPP)