Patterns of 0's and 1's

#include
using namespace std;

int main()
{
int n;
int val;
cin>>n;

for(int i=1;i<=n;i++)
   val= (i%2)==0?(val=1):(val=0);
   for(int cnt=1;cnt<=i;cnt++)
   {
      cout<<val;
      val=1-val;
  }
  return 0;

}

GETTING AN ERROR STATING THAT ’ name lookup of ‘i’ changed for ISO ‘for’ scoping[-fpermissive]

Hey @dsdishu99
You need to add a bracket to : for(int i=1;i<=n;i++) loop

If your doubt is resolved please mark it as closed.

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.