write the program for prime numbers?

Answer Posted / ashok

void main()
{
int i,n;
clrscr();
printf("\nEnter the range:");
scanf("%d",&n)
printf("Prime numbers are:");
for(i=1;i<=n;i++)
{
if(i==2 || i==3 || i==5 || i==7)
printf("%d ",i);
if(i%2!=0 && i%3!=0 && i%5!=0 && i%7!=0)
printf("%d ",i);
}
getch();
}

Is This Answer Correct ?    7 Yes 8 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the types of data structures in c?

606


Explain why c is faster than c++?

579


4. main() { int c=- -2; printf("c=%d",c); }

1373


Explain the difference between malloc() and calloc() in c?

581


Disadvantages of C language.

664






What is a struct c#?

604


what is associativity explain what is the precidence for * and & , * and ++ how the folloing declaration work 1) *&p; 2) *p++;

1892


What is merge sort in c?

649


a program that can input number of records and can view it again the record

1488


What would be an example of a structure analogous to structure c?

578


What does a pointer variable always consist of?

667


What is identifier in c?

551


What are the features of c languages?

633


What is a pointer in c plus plus?

698


Write the syntax and purpose of a switch statement in C.

631