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

Answer Posted / smi

/* Program to print all prime number between a range through
function */
#include
#include
void print_prime(int r1,int r2)
{
int n=0,d=0,j;
clrscr();
for(n=r1;n<=r2;++n)
{
for(j=2;j
{
if(n%j==0)
{
d++;
break;
}
}
if(d==0)
printf("\t%d",n);
d=0;
}
}
void main()
{
int n1=0,n2=0;
printf("\n Enter range1 & range2 =>");
scanf("%d%d",&n1,&n2);
print_prime(n1,n2);
getch();
}

Is This Answer Correct ?    26 Yes 47 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain what is the best way to comment out a section of code that contains comments?

724


What does malloc () calloc () realloc () free () do?

563


what does static variable mean?

657


I need a help with a program: Write a C program that uses data input in determining the whole of points A and a whole of circles B. Find two points in A so that the line which passes through them, cut through the maximum number of circles.

1500


What does & mean in scanf?

606






How do I copy files?

625


Why do we use null pointer?

609


any restrictions have on the number of 'return' statements that may be present in a function. a) no restriction b) only 2 return statements c) only 1 return statements d) none of the above

663


Why is c so powerful?

691


What is 'bus error'?

651


What is 2 d array in c?

560


What are compound statements?

631


C language questions for civil engineering

1248


What is call by reference in functions?

573


What do the functions atoi(), itoa() and gcvt() do?

726