#include <iostream>
#include<conio.h>
using namespace std;
int prime(int a)
{
int count=0;
for(int i=2;i<a;i++)
{
if(a%i==0)
{
count++;
}
}
if(count==0)
{
cout<<"\nThe number "<<a<<" is prime"<<endl;
}
else
{
cout<<"\nThe number "<<a<<" is not prime"<<endl;
}
return a;
}
int main()
{
int x,i=0;
//loop to take input 5 time from user
while(i<5)
{
cout<<"Enter a number : ";
cin>>x;
prime(x);
i++;
}
}
No comments:
Post a Comment