#include
using namespace std;
int main()
{
int n,k;
cin>>n>>k;
for(int i=1;i<=n;i++)
{
int num=(3*i)+2;
if(num%k!=0)
{
cout<<num<<endl;
}
}
}
this is my code what is the error in this code
#include
using namespace std;
int main()
{
int n,k;
cin>>n>>k;
for(int i=1;i<=n;i++)
{
int num=(3*i)+2;
if(num%k!=0)
{
cout<<num<<endl;
}
}
}
this is my code what is the error in this code
Hello Sarwarul,
Actually you need to run your loop for more than n times to print n required numbers.
Hint use while and maintain a counter.
I hope you find this helpful.
Regards
Aman yadav
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.