+ 6
program to display all alternate element form 2D array in c++
if the array is containing: 12 45 67 33 90 76 21 43 59 the output will be 12 67 90 21 59
4 Respuestas
+ 2
@jay
I think C++.
@Priyanshu
Use this loop in your program:
for(int i=0;i<n;i++)
{ if(i%2==0)
{ for(int j=0;j<n;j+=2) cout<<mat[i][j]<<" "; }
else
{ for(int j=1;j<n;j+=2) cout<<mat[i][j]<<" "; }
}
If you wish to start from the element [0,1], just interchange the if and else 's code fragments...
+ 10
language?
+ 10
it needs to notify you if person updates the question 😯
0
it needs to notify you if person updates the question 😯