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 reserved words?

658


Using which language Test cases are added in .ptu file of RTRT unit testing???

3605


What is the size of array float a(10)?

659


Where are the auto variables stored?

626


Explain how can you tell whether a program was compiled using c versus c++?

581






A c program to display count values from 0 to 100 and flash each digit for a secong.reset the counter after it reaches 100.use for loop,. pls guys hepl me.. :(

1744


How can I get the current date or time of day in a c program?

654


In a switch statement, explain what will happen if a break statement is omitted?

641


#include #include struct stu { int i; char j; }; union uni { int i; char j; }; void main() { int j,k; clrscr(); struct stu s; j=sizeof(s); printf("%d",j); union uni u; k=sizeof(u); printf("%d",k); getch(); } what is value of j and k.

5215


What is d scanf?

597


What do you mean by keywords in c?

632


What is external variable in c?

617


how to count no of words,characters,lines in a paragraph.

3909


Explain the properties of union. What is the size of a union variable

718


What is the meaning of c in c language?

598