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

What is adt in c programming?

598


What is the use of linkage in c language?

604


using for loop sum 2 number of any 4 digit number in c language

1722


What are 3 types of structures?

584


main() { inta=10,b=20; a>=5?b=100:b=200; printf("%d ",b); }

901






Explain the difference between structs and unions in c?

564


What is "Duff's Device"?

694


how logic is used

1490


Explain the Difference between the New and Malloc keyword.

675


Are there constructors in c?

585


How can I write data files which can be read on other machines with different word size, byte order, or floating point formats?

604


What is the difference between the expression “++a” and “a++”?

642


What does a pointer variable always consist of?

653


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

571


What are terms in math?

577