CODE NOT GIVING REQUIRES OUTPUT

package recursion;

public class mazePrint {

public static void mazePrint(int cc,int cr,int ec,int er,String result)
{
	if(cc>ec || cr>er)
	{
		return;
	}
	if(cc==ec && cr==er)
	{
		System.out.println(result);
		return;
	}
	
	mazePrint(cc+1,cr,ec,er,result=result+"H");
	mazePrint(cc,cr+1,ec,er,result=result+"V");
}
public static void main(String[] args) {
	mazePrint(0,0,2,2,"");

}

}

simply pass result+“H” or v

mazePrint(cc+1,cr,ec,er,result+“H”);

mazePrint(cc,cr+1,ec,er,result+"V");

if this resolves your doubt please mark it as resolved nad rate as well :slight_smile:

pls try to give explaination why is wrong in my code and why i can’t write that

when u pass a value to a function with variable say result and you want to update the value for result ,just write the updated value in the function call,it ll automaticaly be equated to the ‘result’ variable, the way you have written will make it something like passing result+=“H” which is more additions than we require here