# i don't know what is wrong when i run the program the output is all zeros

``````void blur(int height, int width, RGBTRIPLE image[height][width])
{
double red_sum ;
double green_sum ;
double blue_sum ;
double counter;
RGBTRIPLE new_image[height][width];

for(int k=0; k < height; k++)
{
for(int m=0; m < width; m++)
{
new_image[k][m].rgbtGreen = image[k][m].rgbtGreen;
new_image[k][m].rgbtRed = image[k][m].rgbtRed;
new_image[k][m].rgbtRed = image[k][m].rgbtBlue;
}
}

for(int i = 0 ; i < height ; i++)
{
for(int j = 0; j < width ; j++)
{
counter =0;
red_sum =0;
blue_sum=0;
green_sum=0;

for(int box_height = i-1; box_height == i+1 ; box_height++)
{
for(int box_width = j-1; box_width == j+1 ; box_width++)
{
if( box_height < 0 || box_width < 0 || box_height == height  || box_width == width)
{
continue;
}
red_sum += new_image[box_height][box_width].rgbtRed;
blue_sum += new_image[box_height][box_width].rgbtBlue;
green_sum += new_image[box_height][box_width].rgbtGreen;
counter++;
}
}
image[i][j].rgbtRed = round(red_sum / counter);
image[i][j].rgbtBlue = round(blue_sum / counter);
image[i][j].rgbtGreen = round(green_sum / counter);
}
}
}
``````

## 1 Answer

This looks familiar. Look at the for loop setups:

``````        for(int box_height = i-1; box_height == i+1 ; box_height++)
{
for(int box_width = j-1; box_width == j+1 ; box_width++)
``````

Do these for loops ever actually execute? Does a for loop run while or until the test is true?

• The program executes normally but when i run check50 the results is all a zeros – Muhammed Jul 12 '20 at 20:38