diff --git a/CPP_Programming/CheckPrime.cpp b/CPP_Programming/CheckPrime.cpp index 1b41633..9098447 100644 --- a/CPP_Programming/CheckPrime.cpp +++ b/CPP_Programming/CheckPrime.cpp @@ -2,17 +2,22 @@ #include using namespace std; - +int prime(int n) +{ + int flag=0; + for (int i=2; i<=n/2; i++) { + if (n%i==0) + flag=1; + } + return flag; +} int main() { - int n,i,flag=0; + int n,ans=0; cout<<"Enter any number: "; cin>>n; - for (i=2; i<=n/2; i++) { - if (n%i==0) - flag=1; - } - if (flag==0) + + if (prime(n)) cout< +#include +using namespace std; #include -void main() { +int main() { + - clrscr(); int a,b,N,D,R=1,HCF; - cout<<"\nEnter 2 numbers: "; + cout<<"Enter 2 numbers: "<>a>>b; if (a>b) { N=a; @@ -31,5 +32,5 @@ void main() { } } cout<<"HCF of "<