Program to find out the given number is prime or not
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
//Program to find out the given number is prime or not
int i,num,count;
cout<<"Enter any number :";
cin>>num;
count = 0;
i=1;
do{
if(num%i==0)
count=count+1;
i++;
}while(i<=num);
if(count==2){
cout<<"The number is Prime ";
}
else{
cout<<"The number is not prime";
}
getch();
return 0;
}
#include <conio.h>
using namespace std;
int main()
{
//Program to find out the given number is prime or not
int i,num,count;
cout<<"Enter any number :";
cin>>num;
count = 0;
i=1;
do{
if(num%i==0)
count=count+1;
i++;
}while(i<=num);
if(count==2){
cout<<"The number is Prime ";
}
else{
cout<<"The number is not prime";
}
getch();
return 0;
}
Comments
Post a Comment