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 a macro in c preprocessor?
How to find a missed value, if you want to store 100 values in a 99 sized array?
Is null a keyword in c?
What is maximum size of array in c?
Why we use break in c?
HOW TO SOLVE A NUMERICAL OF LRU IN OS ??????
What are type modifiers in c?
Why doesnt long int work?
What is the significance of c program algorithms?
When is a void pointer used?
What are header files in c programming?
How can a string be converted to a number?
A c program to display count values from 0 to 100 and flash each digit for a secong.reset the counter after it reaches 100.use for loop,. pls guys hepl me.. :(
C program to find all possible outcomes of a dice?
Explain is it better to bitshift a value than to multiply by 2?