67 224
Assignments Done
99,2%
Successfully Done
In November 2018

Answer to Question #24701 in C++ for EMMANUEL

Question #24701
write a function which outputs all prime numbers between 2 and a given positive integer n;
void primes(unsigned int n);
Expert's answer
#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!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions