Write a program to print all the prime numbers with in the
given range

Answer Posted / om

void find_primenumber_in_range(int r1,int r2)
{
int i,j;
for(i=r1;i<=r2;i++)
{
for(j=2; j<=(i/2); j++)
if(i%j==0)
break;
if(j== (i/2 +1))
printf("%d\t",i);
}
}

Is This Answer Correct ?    31 Yes 21 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a good data structure to use for storing lines of text?

580


What is getch() function?

630


What is the use of getch ()?

614


Can a pointer be volatile in c?

520


List the variables are used for writing doubly linked list program.

1606






I need a help with a program: Write a C program that uses data input in determining the whole of points A and a whole of circles B. Find two points in A so that the line which passes through them, cut through the maximum number of circles.

1478


What are all different types of pointers in c?

562


What is an lvalue in c?

684


What is the purpose of macro in C language?

651


Is Exception handling possible in c language?

1564


Explain what is the difference between a string and an array?

620


What is the difference between union and structure in c?

560


What does typeof return in c?

627


What is the benefit of using const for declaring constants?

574


Write a C program that will accept a hexadecimal number as input and then display a menu that will permit any of the following operations to be carried out: Display the hexadecimal equivalent of the one's complement. (b) Carry out a masking operation and then display the hexadecimal equivalent of the result. (c) Carry out a bit shifting operation and then display the hexadecimal equivalent of the result. (d) Exit. If the masking operation is selected, prompt the user lor the type of operation (bitwise and, bitwise exclusive or, or bitwise or) and then a (hexadecimal) value for the mask. If the bit shifting operation is selected. prompt the user for the type of shift (left or right), and then the number of bits. Test the program with several different (hexadecimal) input values of your own choice.

4820