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 pointers in c with example?
Is it better to bitshift a value than to multiply by 2?
What is the use of ?: Operator?
What is p in text message?
Hi can anyone tell what is a start up code?
Explain what is meant by 'bit masking'?
What is an lvalue in c?
write a program in C that prompts the user for today's date,tomorrow's date and display the results.Use structures for today's date,tomorrow's date and an array to hold the days for each month of the year.
What is pointers in c?
Why c language?
what is different between auto and local static? why should we use local static?
What is data types?
Explain what header files do I need in order to define the standard library functions I use?
What is the use of bitwise operator?
What is variable and explain rules to declare variable in c?