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

What does %2f mean in c?

1002


i have to apply for rbi before that i need to know the the syllabus for the entrance questions. whethet it may be aps or techinical

2128


How to explain the final year project as a fresher please answer with sample project

753


A float occupies 4 bytes in memory. How many bits are used to store exponent part? since we can have up to 38 number for exponent so 2 ki power 6 6, 6 bits will be used. If 6 bits are used why do not we have up to 64 numbers in exponent?

2093


Why do we use header files in c?

846


When a c file is executed there are many files that are automatically opened what are they files?

853


What is variable declaration and definition in c?

722


What is an array in c?

815


What is chain pointer in c?

816


What is advantage of pointer in c?

945


Why c is called top down?

888


Write a program to know whether the input number is an armstrong number.

937


Explain the difference between call by value and call by reference in c language?

901


write a program to rearrange the array such way that all even elements should come first and next come odd

2058


What is calloc() function?

882