//Program to check whether the given number is Prime or Not.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int N,flag=0;
cout<<"\nEnter number to check whether it is prime or not:";
cin>>N;
for(int i=2;i<N;i++)
{
if(N%i==0)
flag=1;
}
if(flag==1)
cout<<"\nIt is not a prime number!";
else if(flag==0)
cout<<"\nThe given number is a prime number!";
getch();
}
STERBOG
Get common C++ programs over here. Contains CBSE, ICSE, SSC and all boards prescribed problems for computer science (CS) and information practices (IP).Have doubts? Need Help? Post your quires and surely we will provide you with the solution!
Monday, February 8, 2016
C++ Program to Check Whether a give number is Prime or Not
Labels:
.cpp,
computer,
computer science,
ICSE,
maths,
prime number,
SSC,
turbo c++
Subscribe to:
Posts (Atom)