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

Answer Posted / ankit giriya

#include<stdio.h>
void main()
{
int i, prime, lim_up, lim_low, n;
clrscr();
printf(“\n\n\t ENTER THE LOWER LIMIT…: “);
scanf(“%d”, &lim_low);
printf(“\n\n\t ENTER THE UPPER LIMIT…: “);
scanf(“%d”, &lim_up);
printf(“\n\n\t PRIME NUMBERS ARE…: “);
for(n=lim_low+1; n<lim_up; n++)
{
prime = 1;
for(i=2; i<n; i++)
if(n%i == 0)
{
prime = 0;
break;
}
if(prime)
printf(“\n\n\t\t\t%d”, n);
}
getch();
}

Is This Answer Correct ?    4 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is c++ used for today?

665


How can I manipulate individual bits?

608


What are header files and explain what are its uses in c programming?

612


What is optimization in c?

568


What is use of pointer?

587






How can I read in an object file and jump to locations in it?

579


What does a pointer variable always consist of?

665


If the size of int data type is two bytes, what is the range of signed int data type?

594


What does it mean when a pointer is used in an if statement?

602


Are bit fields portable?

679


Can you explain what keyboard debouncing is, and where and why we us it? please give some examples

1659


What are the advantages of using Unions?

642


how to create duplicate link list using C???

2075


By using C language input a date into it and if it is right?

574


What are linked lists in c?

651