Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

c++ program to find prime number using function

#include<iostream>
using namespace std;
bool isPrimrNumber(int number){
	bool isPrimeFlag=true;
	for(int i=2;i<number;i++){
	if(number%i==0){
		isPrimeFlag=false;
		break;
	}
}
		return isPrimeFlag;
}
int main()
{
	int number;
	cout<<"Please enter your number";
	cin>>number;
		bool isPrimeFlag=isPrimeNumber(number)
	if(isPrimeFlag)
	{
		cout<<"prime Number";
	}
	else
	{
		cout<<"not prime number";
	}
}
Source by codejudge.blogspot.com #
 
PREVIOUS NEXT
Tagged: #program #find #prime #number #function
ADD COMMENT
Topic
Name
4+3 =