Home > Blockchain >  What am I doing wrong with this for loop in C?
What am I doing wrong with this for loop in C?

Time:11-30

I'm trying to implement the below code in a for loop, to avoid needing to have every XOR term written out separately.

unsigned int check_0 = P0^en[2]^en[4]^en[6]^en[8]^en[10]^en[12]^en[14]^en[16]^en[18]^en[20]^en[22]^en[24]^en[26]^en[28]^en[30];

This is what I've written, but it doesn't work. Can someone please let me know what I'm doing wrong?

unsigned int check_0z = P0;
unsigned int check_0 = 0;

 int i = 2;
  for (i = 2; i > 30; i  = 2){
    check_0 = check_0z^en[i];
    check_0z = check_0;
  }

CodePudding user response:

I can use while or do... while instead of for loop. That is suitable.

CodePudding user response:

first of all P0 and en are not declared. Please elaborate what you are trying to do. Also in for loop there should be i<=30.

  • Related