#include <iostream>
using namespace std;

int main() {
    int arr[3]={2,3,4};
    for(int i=0;i<3;i+=2)
        {
            if((i+1)<3)
            {
              swap(arr[i],arr[i+1]);
            }
            
        }
    for(int i=0;i<3;i++)
        {
            cout<<" "<<arr[i];
        }
    return 0;
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: