Revert(A,B); //This will add 1,2,3,4,5 successively to number A making it 21,23,26,30 and 35 as per logic since B is 4 and it will allow loop to run for 5 times as Last will become 5
cout<<A<<“&”<<B<<endl; // This will print 35&4 as per logic
B–; //B reduced to 3 after this instruction Revert(A,B); //This will add 1,2 successively to number A which is now 35 (as A is passed by reference) making it 36,38 as per logic since B is 3 and it will allow loop to run for 2 times as Last will become 2
cout<<A<<“#”<<B<<endl; // This will print 38&3 as per logic
Revert(B); //This will add 1,2,3 successively to number B making it 4,6,9 as per logic since second param will take default value of 2 and it will allow loop to run for 3 times as Last will become 3 cout<<A<<“#”<<B<<endl; // This will print 38#9 as per logic
Common Errors
Student often forget that the number is being added successively to initial number and not at once.