Write a program to print all the prime numbers with in the
given range

Answer Posted / roopa

#include<stdio.h>
#include <conio.h>


main()

{
int n1=0,n2=0;
printf("enter the range\n");
scanf("%d %d", &n1, &n2);
prime(n1,n2);
getch();
}

int prime(int n1, int n2)
{

int i,j;
for (i=n1;i<=n2;++i)

{
for(j=2;j<=(i/2);j++)
{
if(i%j==0)
{

break;
}
}
if(j==(i/2+1))
printf("%d\n", i);

}
}

Is This Answer Correct ?    31 Yes 17 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What's the total generic pointer type?

600


Explain how does flowchart help in writing a program?

615


What is malloc() function?

627


What is c programming structure?

606


What is the difference between break and continue?

596






What is meant by high-order and low-order bytes?

640


When a c file is executed there are many files that are automatically opened what are they files?

578


What is identifiers in c with examples?

665


largest Of three Number using without if condition?

989


What is call by value in c?

544


the statement while(i) puts the entire logic in loop. this loop is called a) indefinite loop b) definite loop c) loop syntax wrong d) none of the above

592


Why functions are used in c?

570


In c programming language, how many parameters can be passed to a function ?

617


write a program for the normal snake games find in most of the mobiles.

1772


Differentiate between a structure and a union.

748