0
can anyone please make me understand the "for" part of this code...(why we hav taken "j<=i/2" and why we hav used two loops?
// code for printing a range of primary numbers #include <iostream> using namespace std; int main() { int n,cnt=1,i=3,flag; cout<<"How many numbers? "; cin>>n; cout<<"\nFirst "<<n<<" Prime numbers:"<<endl; cout<<"2"; while(cnt<n) { flag=0; for(int j=2;j<=i/2;j++) if(i%j==0) { flag=1; break; } if(flag==0) { cout<<", "<<
1 Antwort