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
Which one would you prefer - a macro or a function?
Explain how can I avoid the abort, retry, fail messages?
What is c variable?
How do you override a defined macro?
Explain what are the different file extensions involved when programming in c?
How can variables be characterized?
Why are algorithms important in c program?
Write a program to replace n bits from the position p of the bit representation of an inputted character x with the one's complement. Method invertBit takes 3 parameters x as input character, p as position and n as the number of positions from p. Replace n bits from pth position in 8 bit character x. Then return the characters by inverting the bits.
Give basis knowledge of web designing ...
Write a program to print fibonacci series without using recursion?
How can I convert a number to a string?
If fflush wont work, what can I use to flush input?
What does dm mean sexually?
Lists the benefits of c programming language?
Explain how do you view the path?