Answer to Question #19374 in C++ for madridi

Question #19374
Write a program that asks the user to enter a positive number then displays all numbers less or equal to it that are prime.
1
Expert's answer
2012-11-26T06:07:07-0500
#include<iostream>
using namespace std;
int main ()
{
int num, a;
cout << "Enter A Positive integer :"<<endl;
cin >> num;
cout<<" The Prime numbers are: " ;
for(int i = 2; i < num; i++){
& if(i%2!=0){
& cout << i <<endl;
& }
}
system("pause");
return 0;
}


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS