My code is working on Dev C++ Compiler. It is showing bus error. Please have a look. and i have a advice please let us see test case if one or two not working, we get a chance to understand and improve our code
I dont get the doubt
@dhruvtrehan45 hey you have some problem in your logic ,you have to print row wise the element ,but you have print column wise ,see the sample test case you will get it.
#include
using namespace std;
main()
{
int rows;
int cols;
cin>>rows>>cols;
int a[rows][cols];
for(int i = 0 ; i < rows ; i++)
{
for(int j = 0 ; j < cols ; j++)
{
cin>>a[i][j];
}
}
for(int i = 0 ; i < cols ; i++)
{
if( i % 2 == 0)
{
for(int j = 0 ; j < rows ; j++)
{
cout<<a[i][j]<<", β;
}
}
else
{
for(int j = rows -1 ; j >= 0 ; jβ)
{
cout<<a[i][j]<<β, ";
}
}
}
cout<<βENDβ;
}
Please tell the error in my code. Ignore the header file. That I have written
I hope Iβve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.