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
shorting algorithmS
What does sizeof int return?
What is a pointer variable in c language?
What does sizeof return c?
What is a structure member in c?
Explain what is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?
What is variable and explain rules to declare variable in c?
How #define works?
What is the use of c language in real life?
What is pragma in c?
4-Take two sets of 5 numbers from user in two arrays. Sort array 1 in ascending and array 2 in descending order. Perform sorting by passing array to a function mySort(array, sortingOrder). Then multiply both the arrays returned from function, using metric multiplication technique in main. Print result in metric format.
Write a code of a general series where the next element is the sum of last k terms.
How do you define structure?
What are header files and explain what are its uses in c programming?
What are predefined functions in c?