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

Answer Posted / pooja mishra

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int range,c;
cout<<"enter the range";
cin>>range;
for(int i=1;i<=range;i++)
{
c=0;
for(int j=2;j<i;j++)
{
if(i%j==0)
c++;
}
if(c==o)
cout<<i<<"\n";
}
getch();
}

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can you pass an entire structure to functions?

680


What is the translation phases used in c language?

616


What is a function simple definition?

600


is it possible to create your own header files?

623


What is a example of a variable?

537






using only #include and #include Write a program in C that will read an input from the user and print it back to the user if it is a palindrome. The string ends when it encounters a whitespace. The input string is at most 30 characters. Assume the string has no spaces and distinguish between and lowercase. So madam is a palindrome, but MadAm is not a palindrome. Use scanf and %s to read the string. Sample Test: Enter a string: madam madam is a palindrome. Enter a string: 09023 09023 is not a palindrome.

1298


List some basic data types in c?

547


What is sizeof int?

620


Explain why c is faster than c++?

560


What are pointers in C? Give an example where to illustrate their significance.

735


What are pointers? Why are they used?

618


What is use of integral promotions in c?

648


Which is more efficient, a switch statement or an if else chain?

565


What is a ternary operator in c?

636


Which is best linux os?

546