write the program for prime numbers?

Answer Posted / farhana parvin sunny

#include<stdio.h>

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 ?    1 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can I get back to the interactive keyboard if stdin is redirected?

673


In C programming, what command or code can be used to determine if a number of odd or even?

627


What are different storage class specifiers in c?

623


What is far pointer in c?

815


cin.ignore(80, _ _);This statement a) ignores all input b) ignores the first 80 characters in the input c) ignores all input till end-of-line d) iteration

640






What are register variables in c?

577


a character or group of characters that defines a register,or a part of storage a) memory b) byte c) address d) linear list

634


What are the main characteristics of c language describe the structure of ac program?

616


Why is c so popular?

654


Explain how can I make sure that my program is the only one accessing a file?

635


What are the applications of c language?

630


What is a global variable in c?

594


What is volatile variable in c?

660


What is modeling?

651


Explain what is gets() function?

639