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
What is c++ used for today?
How can I manipulate individual bits?
What are header files and explain what are its uses in c programming?
What is optimization in c?
What is use of pointer?
How can I read in an object file and jump to locations in it?
What does a pointer variable always consist of?
If the size of int data type is two bytes, what is the range of signed int data type?
What does it mean when a pointer is used in an if statement?
Are bit fields portable?
Can you explain what keyboard debouncing is, and where and why we us it? please give some examples
What are the advantages of using Unions?
how to create duplicate link list using C???
By using C language input a date into it and if it is right?
What are linked lists in c?