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 are the preprocessor categories?

836


i want to switch my career from quailty assurance engineering to development kindly guide me from which programming language its better for me to start plz refer some courses or certifications too i have an experience of 1.5 yrs in QA field.Kindly guide me

1678


What is sizeof array in c?

784


Explain why can’t constant values be used to define an array’s initial size?

1110


what is the difference between class and unio?

2114


What the advantages of using Unions?

926


How can you find the exact size of a data type in c?

789


What are pointers? Why are they used?

869


Can you subtract pointers from each other? Why would you?

757


how could explain about job profile

1661


What is null in c?

767


Create a structure to specify data on students as given below: Roll number, Name, Department, Course, and Year of joining. Assume that there are not more than 450 students in the collage. (a) Write a function to print the names of all students who joined in the last 3 years. (b) Write a function to print the data of a student whose roll numbers are divisible by 4.

887


How can I use a preprocessorif expression to ?

791


Why enum is used in c?

709


What is scope rule of function in c?

792