Shortest path string

sir i can do it only using loops its working fine but is there any other way to do it without using loop
because we need a letter x times if x=+4 and y=+5
then we need to print EEEENNNNN like that we can do using loops only as i think pls do me correct if i am wrong

You have to do it using loops but you can shorten the code. Notice that both and x and y are independent variables, so you can use if conditions on them individually.
From line 22 you can write something like this.
if(x > 0){
while(x–) cout<<“E”;
}
else{
x = abs(x);
while(x–) cout<<“W”;
}
if(y > 0){
while(y–) cout<<“N”;
}
else{
y = abs(y);
while(y–) cout<<“S”;
}

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.