So does this look right? Im suspecting if i use the same variable "int tmp" for both would that cause any issues? Or do i even need "int tmp" for the second one?

/* change color image to black and white */

Code:

void BlackNWhite(unsigned char R[WIDTH][HEIGHT], unsigned char G[WIDTH][HEIGHT],unsigned char B[WIDTH][HEIGHT])
{
int tmp;//should i assign this to anything?
for (int y = 0; y < HEIGHT; y++)
for (int x = 0; x < WIDTH; x++)
{
tmp = (R[x][y] + G[x][y] + B[x][y])/ 3;
R[x][y] = G[x][y] = B[x][y] = tmp;
/* R[x][y] = (R[i][j]+G[i][j]+B[i][j])/3;
G[x][y] = (R[i][j]+G[i][j]+B[i][j])/3;
B[x][y] = (R[i][j]+G[i][j]+B[i][j])/3;*/
}
}

/* reverse image color */

Code:

void Negative(unsigned char R[WIDTH][HEIGHT], unsigned char G[WIDTH][HEIGHT], unsigned char B[WIDTH][HEIGHT])
{
int tmp;
for (int y = 0; y < HEIGHT; y++)
for (int x = 0; x < WIDTH; x++)
{
R[x][y] = 255 - R[x][y];
G[x][y] = 255 - G[x][y];
B[x][y] = 255 - B[x][y];
}
}