MENU
Question -

Write a user-defined function swap_row(int ARR[][3],int R,int C) in C++ to swap the first row values with the last row values : For example:

10 20 30
40 50 60
70 80 90
Then after function call,the content of the array should be:

70 80 90
40 50 60
10 20 30



Answer -

voidswap_row (intARR [] [3] , int R,int() )
 {
 for(int i=0 J=0: J
 {
 int temp=ARR[i][j];
 ARR[i][j]=ARR[R-1][j];
 ARR[R-1][j]=temp;
 }
 }

Comment(S)

Show all Coment

Leave a Comment

Free - Previous Years Question Papers
×