Write a program to swap to integer pointers

Write a program to swap to integer pointers

Ques:- Write a program to swap to integer pointers
1 7438

One Answer on this Question

  1. arr=[2,3,4,5]
    for(let i =0; i<arr.length; i++){
    for(let j =i+1; j<arr.length; j++){

    if(arr[i]+arr[j]==8){
    // console.log(arr[i],arr[j]);
    temp=arr[i]
    arr[i]=arr[j]
    arr[j]=temp
    }
    }

    }
    console.log(arr)

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top