write the program for prime numbers?

Answer Posted / sham

int main()
{
int i,j,n,f=0;
printf("Enter the length\n");
scanf("%d",&n);
for(i=2;i<=n;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 ?    180 Yes 107 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can I read and write comma-delimited text?

625


Write a program for finding factorial of a number.

637


What are different storage class specifiers in c?

623


Can a function argument have default value?

676


What does %p mean?

603






What is a function simple definition?

625


simple program of graphics and their output display

1471


What are the functions to open and close the file in c language?

597


if p is a string contained in a string?

1409


What is echo in c programming?

561


What is a double c?

595


What is #line?

615


Differentiate between null and void pointers.

635


How macro execution is faster than function ?

673


which of the following is not a character constant a) 'thank you' b) 'enter values of p, n ,r' c) '23.56E-o3' d) all of the above

1421