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's the total generic pointer type?
Explain how does flowchart help in writing a program?
What is malloc() function?
What is c programming structure?
What is the difference between break and continue?
What is meant by high-order and low-order bytes?
When a c file is executed there are many files that are automatically opened what are they files?
What is identifiers in c with examples?
largest Of three Number using without if condition?
What is call by value in c?
the statement while(i) puts the entire logic in loop. this loop is called a) indefinite loop b) definite loop c) loop syntax wrong d) none of the above
Why functions are used in c?
In c programming language, how many parameters can be passed to a function ?
write a program for the normal snake games find in most of the mobiles.
Differentiate between a structure and a union.