Write a program to print all the prime numbers with in the
given range
Answer Posted / roopa
#include<stdio.h>
#include <conio.h>
main()
{
int n1=0,n2=0;
printf("enter the range\n");
scanf("%d %d", &n1, &n2);
prime(n1,n2);
getch();
}
int prime(int n1, int n2)
{
int i,j;
for (i=n1;i<=n2;++i)
{
for(j=2;j<=(i/2);j++)
{
if(i%j==0)
{
break;
}
}
if(j==(i/2+1))
printf("%d\n", i);
}
}
Is This Answer Correct ? | 31 Yes | 17 No |
Post New Answer View All Answers
What is double pointer in c?
What is the size of a union variable?
What are pointers? What are stacks and queues?
When is a “switch” statement preferable over an “if” statement?
Do string constants represent numerical values?
Compare array data type to pointer data type
What are the differences between Structures and Arrays?
What kind of structure is a house?
I need testPalindrome and removeSpace
#include
How can I access an I o board directly?
What is the difference between null pointer and wild pointer?
Why doesnt that code work?
What is the use of getch ()?
Which is better pointer or array?
What is array in c with example?