write the program for prime numbers?

Answer Posted / gnanasekaran

int main()
{
int i,j,n,f=0;
printf("Enter the length\n");
scanf("%d",&n);
for(i=2;i<=n/2;i++)
{
for(j=2;j<i;j++)
{
if((i%j)==0)
{
f=1;
break;
}
f=0;
}
if(f==0)
printf("%d ",i);
}
}

Is This Answer Correct ?    139 Yes 81 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are linker error?

612


write a proram to reverse the string using switch case?

2461


What is extern keyword in c?

639


#define MAX(x,y) (x) >(y)?(x):(y) main() { inti=10,j=5,k=0; k= MAX(i++,++j); printf("%d..%d..%d",i,j,k); }

774


Write a program to check armstrong number in c?

633






please explain every phase in the "SDLC" in the dotnet.

2175


What is the concatenation operator?

606


What is a stream?

642


What is the difference between exit() and _exit() function in c?

578


What is the best way to store flag values in a program?

578


What is a good way to implement complex numbers in c?

591


What is the difference between void main and main in c?

621


What do you mean by recursion in c?

621


Is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?

648


Explain what is dynamic data structure?

642