## Saturday, September 22, 2012

### C++ PROGRAM TO CHECK WHETHER A NUMBER IS CIRCULAR PRIME OR NOT

The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719, are themselves prime.

1. Super logic.............

2. Prime number program in C++

prime number is only divisible by 1 and itself,
we can easily write prime number program in c++, just check number is not divisible by any other numbers except 1 and number itself.

3. Prime number program in C++

A prime number is a natural number which is greater than 1 and these numbers are only divisible by 1 and itself number. In programming point of view, we check condition number is divisible by other number or not except 1 and number itself. If number is not divisible by other number than that number is prime number.

4. can you write the program with using only while loop?

1. You mean avoid the usage of do-while ??

5. This code is correct ?Prime Number Program in C

#include
#include
void main()
{
int num,res=0;
clrscr();
printf("\nENTER A NUMBER: ");
scanf("%d",&num);
res=prime(num);
if(res==0)
printf("\n%d is a prime number",num);
else
printf("\n%d is not a prime number",num);
getch();
}
int prime(int n)
{
int i;
for(i=2;i<=n/2;i++)
{
if(n%i!=0)
continue;
else
return 1;
}
return 0;
}

6. This code is frequently ask in any examination Prime number program in C++ is very simple and easy to write. Using for loop and if else we can write this code.