PRINT ALTERNATE PRIME NUMBERS IN C PROGRAMMING
Answers
Answered by
0
you are asking to print 2 ,5 ,11 like that ,na?
so just do take another variable make it 0 for ease.
int i=0;
ok every time you go to print a prime number . check if the value of i is 0.
if the value is Zero and print it. otherwise or else Dont do anything.
and make sure for every prime number going in to check for print or not .make sure change i to be Change to 0->1 and 1->0
int print(int x,int i){
if(i==0){
printf(“%d”,x);
}
return (i==0)?1:0;
}
done now call the function with some i and it will return alternate i.
example
i=0
for every prime number:
i=print(prime,i)
and it will print alternate prime numbers.
hope it helps you
so just do take another variable make it 0 for ease.
int i=0;
ok every time you go to print a prime number . check if the value of i is 0.
if the value is Zero and print it. otherwise or else Dont do anything.
and make sure for every prime number going in to check for print or not .make sure change i to be Change to 0->1 and 1->0
int print(int x,int i){
if(i==0){
printf(“%d”,x);
}
return (i==0)?1:0;
}
done now call the function with some i and it will return alternate i.
example
i=0
for every prime number:
i=print(prime,i)
and it will print alternate prime numbers.
hope it helps you
Similar questions