Print series problem


when i am running it ,its showing compiled succesfully,but not producing any output. can u tell my error in code?

Hey @lovely
There are lots of logical errors ,please revisit ur basics

#include <iostream>
using namespace std;
int main() {
    int n1,n2;
     cin>>n1>>n2;//change 1 : n1>>n2 instead of n1,n2
    int n=1;
    // while(n1<=100 &&n2<=100)//Why are u even doing this
    // {   
    for(int counter=1;counter<=n1;) //chnaged var name and also removed counter ++ as we have to do that inside
       {    
        // cin>>n; why are u even inputting here 
        if((3*n+2)%n2!=0)
        {
         cout<<3*n+2<<endl;
         counter++; //here counter++ instead of n++
        }
    n++;//we will keep doinf n++ until n1 nos are found
        //  else why will we break
        //  {
        //    break;
        //  }
         
    }
     
    // }

   return 0; 
}

ok ,i will do.thanks for answering in so much detail . :+1:

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.