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
What is the use of function in c?
Explain what is page thrashing?
Explain about block scope in c?
What are the benefits of c language?
What is c language used for?
How do you generate random numbers in C?
What is the use of ?: Operator?
What is a list in c?
What is the function of volatile in c language?
What is the difference between c and python?
what is associativity explain what is the precidence for * and & , * and ++ how the folloing declaration work 1) *&p; 2) *p++;
I just typed in this program, and it is acting strangely. Can you see anything wrong with it?
What is a global variable in c?
What is switch in c?
What is the value of a[3] if integer a[] = {5,4,3,2,1}?