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
Explain how many levels deep can include files be nested?
A variable that is defined in a specified portion of a program but can be used throughout the program a) global variable b) local variable c) character d) none
disply the following menu 1.Disply 2.Copy 3.Append; as per the menu do the file operations 4.Exit
What is int main () in c?
Where static variables are stored in memory in c?
Why c is called object oriented language?
How can a process change an environment variable in its caller?
What is the heap?
What is call by reference in functions?
Is c a great language, or what?
What is main () in c?
How do we print only part of a string in c?
Is there a way to jump out of a function or functions?
What are pointers really good for, anyway?
What is the purpose of void pointer?