Mahfuz123

2D array Copy

Jun 29th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int main()
  4. {
  5. int ara[5][5] = {
  6. {1,2,3,4,5},
  7. {10,20,30,40,50},
  8. {100,200,300,400,500},
  9. {500,600,700,800,900},
  10. {1000,2000,3000,4000,5000}
  11. },ara2[5][5],i,j;
  12.  
  13. printf("Before Copy : \n");
  14. for(i=0;i<5;i++){
  15. for(j=0;j<5;j++){
  16. printf("%d ",ara[i][j]);
  17. }
  18. printf("\n");
  19. }
  20. printf("\n");
  21.  
  22.  
  23. //Process for copy.
  24. for(i=0;i<5;i++){
  25. for(j=0;j<5;j++){
  26. ara2[i][j] = ara[j][i];
  27. }
  28. }
  29.  
  30. printf("After Copy : \n");
  31. for(i=0;i<5;i++){
  32. for(j=0;j<5;j++){
  33. printf("%d ",ara2[i][j]);
  34. }
  35. printf("\n");
  36. }
  37. return 0;
  38. }
Add Comment
Please, Sign In to add comment