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
Explain how do you view the path?
How do you write a program which produces its own source code as output?
Can the sizeof operator be used to tell the size of an array passed to a function?
What is the package for freshers(Non IIT) in amazon(hyderabad). And what is the same for those who are a contract employee.
What is call by value in c?
What is c basic?
Can we increase size of array in c?
Explain what does the function toupper() do?
program to find out date after adding 31 days to a date in the month of febraury also consider the leap year
What is a void * in c?
Why is c so popular?
What is line in c preprocessor?
What is volatile, register definition in C
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.
What are the standard predefined macros?