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 null pointer in c?
What is %g in c?
What is pointer to pointer in c with example?
Can variables be declared anywhere in c?
Explain how can I pad a string to a known length?
How do you define structure?
Explain how do you determine whether to use a stream function or a low-level function?
The % symbol has a special use in a printf statement. Explain how would you place this character as part of the output on the screen?
What is declaration and definition in c?
Is there sort function in c?
What is the difference between mpi and openmp?
please give me a VIRTUSA sample palcement papers.... you will only send TECHNICAL SECTION..... that is help for me Advance Thanks........................
What are the 4 data types?
Explain how can I open a file so that other programs can update it at the same time?
i have a written test for microland please give me test pattern