Wednesday, 8 July 2015

prime number in c++

#include<iostream>
using namespace std;
int main()
{
int num;
int i=2;
int c=0;
do{
cout<<"Enter a num: ";
cin>>num;
while(i<num){
if(num%i==0){
c++;
}
i++;
}

{
if(c==0){
cout<<"Num is Prime:\n\n";
}else
cout<<"Num is Not Prime:\n\n";
}
    }while(num==num);
 
return 0;
}

0 comments:

Post a Comment