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

What is bash c?

780


What is a pointer variable in c language?

866


Did c have any year 2000 problems?

900


Explain how does free() know explain how much memory to release?

806


Which one to choose from 'initialization lists' or 'assignment', for the use in the constructor?

822


Write a program to compute the similarity between two strings - The program should get the two strings as input - Then it will output one single number which is the percentage of similarity between the two strings

2494


formula to convert 2500mmh2o into m3/hr

774


List some basic data types in c?

784


What are runtime error?

881


Are pointers integers in c?

841


What are formal parameters?

879


write a c programming using command line argument,demonstrate set operation(eg;union,intersection,difference) example output is c:>setop 12 34 45 1 union 34 42 66 c:>setop 12 34 1 42 66 c:>setop 12 34 diff 12 56 67 78 setop 12 34

1881


Is return a keyword in c?

853


Give the rules for variable declaration?

947


What is array of structure in c programming?

1038