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
Write a program for finding factorial of a number.
how to find binary of number?
Write an algorithm for implementing insertion and deletion operations in a singly linked list using arrays ?
What is break in c?
What are the main characteristics of c language describe the structure of ac program?
Define Spanning-Tree Protocol (STP)
How are structure passing and returning implemented?
Which is the memory area not included in C program? give the reason
What are local static variables?
What is the use of clrscr?
Explain can you assign a different address to an array tag?
Why is sizeof () an operator and not a function?
Place the #include statement must be written in the program?
Calculate the weighted average of a list of n numbers using the formula xavg = f1x1+f2x2+ ….+ fnxn where the f’s are fractional weighting factors, i.e., 0<=fi<1, and f1+f2+….+fn = 1
Explain what is a 'locale'?