C++: Program to find prime no.

#include<iostream>
using namespace std;

int main(){ 
  int i,m=0,flag=0;   
  int n=17;//it is the number to be checked 
  m=n/2;   
  for(i=2;i<=m;i++){   
   if(n%i==0){   
   cout<<"Number is not prime"<<endl;   
   flag=1;   
   break;   
   }   
  }   
  if(flag==0)   
  cout<<"Number is prime"<<endl;   
  return0;
                   < Happy Coding >
In Association with Amazon.in

Comments

Popular Posts

Top 10 Web Sites Every Programmer Should Visit Daily

C++: Huffman Coding using STL

What is "namespace" and why do we use it?