How to remove multiple if else to handle data easily
When dealing with a set of inputs that are all individual pins that might have arbitrary mappings to physical chip pins, the first thing I do is create a function that maps from logical input number to the physical pin:

bool pin_read (int n)
{
  switch (n) {
  case 0: return PORTDbits.RD6;
  case 1: return PORTDbits.RD7;
  /* ... etc. */
  }
}


Note that such a function would normally be one function in a separately-compiled pin module that also contains functions such as pin_write() and pin_direction(). I use a &lt;module&gt;_&lt;method&gt;() naming convention for my C functions, which really helps with keeping track of things as the project grows.

Once you have such a function, everything else can be handled with loops. To capture the status of all of the pins:

for (i=0; i&lt;N_INPUTS; ++i) {
  inputStat[i] = pin_read(i);
}


To print out the previously-captured status:

for (i=0; i&lt;N_INPUTS; ++i) {
  sprintf (temp_buffer, " %d%d", i, inputStat[i]);
  putsUART1(temp_buffer);
}
putsUART1("\n");