Four integer variables , pos1, pos2, pos3, pos4 have been declared and initialized . Write the code necessary to “left rotate” their values : for each variable to get the value of the successive variable , with pos4 getting pos1’s value .

LANGUAGE: JAVA

CHALLENGE:
Four integer variables , pos1, pos2, pos3, pos4 have been declared and initialized . Write the code necessary to “left rotate” their values : for each variable to get the value of the successive variable , with pos4 getting pos1’s value .

SOLUTION:

LANGUAGE: JAVA

CHALLENGE:
Four integer variables , pos1, pos2, pos3, pos4 have been declared and initialized . Write the code necessary to “left rotate” their values : for each variable to get the value of the successive variable , with pos4 getting pos1’s value .

SOLUTION:

int temp = 0;

temp = pos1;
pos1 = pos2;
pos2 = pos3;
pos3 = pos4;
pos4 = temp;