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 is formal argument?

636


Here is a neat trick for checking whether two strings are equal

558


please give me a VIRTUSA sample palcement papers.... you will only send TECHNICAL SECTION..... that is help for me Advance Thanks........................

1535


In C language, the variables NAME, name, and Name are all the same. TRUE or FALSE?

760


How can I access an I o board directly?

614






What is s or c?

584


What language is c written?

568


What are identifiers and keywords in c?

558


Difference between pass by reference and pass by value?

647


What is a program flowchart and explain how does it help in writing a program?

659


Explain what math functions are available for integers? For floating point?

602


What happens if a header file is included twice?

580


how should functions be apportioned among source files?

616


How can I find the modification date of a file?

691


How can you allocate arrays or structures bigger than 64K?

675