Answer to Question #24701 in C++ for EMMANUEL
write a function which outputs all prime numbers between 2 and a given positive integer n;
void primes(unsigned int n);
1
2013-02-20T09:02:15-0500
#include<string>
#include<iostream>
using namespace std;
void primes( int n){
int k=0;
& for( int i=2;i<n;i++){
for( int t=2;t<i;t++)& {
if(i%t==0)
k++;
}
& if(k==0)
& cout<<i<<endl;
& k=0;
&
}& &
& }
int main (){
int n;
cout<<"enter n : ";
cin>>n;
primes( n); &
&
system("PAUSE"); &
}
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!
Learn more about our help with Assignments:
C++
Comments
Leave a comment