//For a number to be a superprime number the first condition is that it should be a prime number. If the number is a prime number, then for it to become superprime the digits in the prime number should also be prime.
For ex: 19 is a prime number; 1 is a prime but 9 is not a prime. Hence 19 is not a superprime number.
13 is a prime number; 1 and 3 both are prime numbers. Hence 13 is a superprime number.
#include <stdio.h>
#include <conio.h>
void superprime(int *p);
int main()
{
int num;
printf("\nEnter an integer number: ");
scanf("%d", &num);
superprime(&num);
getch();
}
void superprime(int *p)
{
int a, digit, d=2, flag=1, f=1, t;
t=*p;
while(d<*p)
{
if((*p%d)==0)
{
flag=0;
break;
}
d++;
}
if(flag==1)
{
f=1;
while(t>0)
{
a=2;
digit=t%10;
while(a<digit)
{
if((digit%a)==0)
{
f=0;
break;
}
a++;
}
t=t/10;
}
}
if(f==1&&flag==1)
printf("\nGiven number is superprime\n");
else if(flag==0)
printf("\nGiven number is not prime\n");
else if(f==0&&flag==1)
printf("\nGiven number is prime but not superprime");
else
printf("\nGiven number is not prime\n");
return;
}
SAMPLE OUTPUT:
3 comments:
it says error c2660: 'superprime' :function does not take 1 parameter
what can i do?
Ok. What you gotta do is after the preprocessor '#include ' there is the function declaration 'void superprime()'. Just make the following correction:
void superprime(int *p).
Some compilers dont support the former syntax.
Necessary changes have been made in the program. You can refer the above program.
Post a Comment