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
Compare array data type to pointer data type
Is null valid for pointers to functions?
What is build process in c?
How can I rethow can I return a sequence of random numbers which dont repeat at all?
What is use of pointer?
Can you please explain the scope of static variables?
What are multidimensional arrays?
Write a program to print "hello world" without using a semicolon?
What are the different types of control structures in programming?
Are local variables initialized to zero by default in c?
Explain data types & how many data types supported by c?
What is the condition that is applied with ?: Operator?
Why main is not a keyword in c?
What language is c written?
Explain how do you generate random numbers in c?