i need help

Hello everyone i'm a new member , i need ur help with this code ,
i want to write a for loop that assigns the 3rd row of the array to 0,, and then print out the array after setting the 3rd row to 0.

``````# include <iostream.h>
int main ()
{
int BL [5][4];
int i,j;
for (i=0;i<5;i++)
{
for (j=0;j<4;j++)
{
BL [i][j]=i+j;
cout<<BL[i][j];
}
cout<<endl<<endl;
}

return 0 ;
}``````

well in the code set i = 2 (for 3rd row ) and iterate only for the j column and set b[j] = 0 ;

``````i =2 ;  // for the 3rd row
for( j = 0 j<5;j++)
b[i][j] = 0;``````

i guess this should work

Fajer91 -4

it's not working with me :\

this code is only to set the 3rd row to zero .
Can u post the new code where u have placed the code i wrote above ?
It would be easier for me to diagnose the problem.

Fajer91 -4

i figured out the answer , thank you very much raul :)
the right code is

``````#include<iostream.h>

int main ()
{
int BL[5][4];
int i,j;

for(i=0;i<5;i++)
{for(j=0;j<4;j++)
{ BL[i][j]=i+j;
cout<<BL[i][j]<<" ";
}
cout<<endl;
}
cout<<endl<<endl;

for(i=0;i<5;i++)
{if(i==2)
{
for(j=0;j<4;j++)
{BL[2][j]=0;
cout<<BL[2][j]<<" ";
}
i++;
cout<<endl;
}
for(j=0;j<4;j++)
{ BL[i][j]=i+j;
cout<<BL[i][j]<<" ";
}
cout<<endl;
}
return 0;
}
``````

please use the code tags while posting ur code , besides instead of this

``````for(i=0;i<5;i++)
{if(i==2)
{
for(j=0;j<4;j++)
{BL[2][j]=0;
cout<<BL[2][j]<<" ";
}``````

u can write it this way .

``````for ( j=0;j<4;j++)
b[2][j] = 0;``````

u can eliminate the other lines of ur code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.