HOMEWORK PROBLEM

#include
using namespace std;
int main()
{
char ch,s=’ ‘;
int x=0,y=0;
ch = cin.get();
while(ch!=’\n’)
{

   if(ch=='E' or ch=='e')
   {
       x++;
   }
   else if(ch=='W' or ch=='w')
   {
       x--;
   }
   else if(ch=='N' or ch=='n')
   {
       y++;
   }
   else
   {
       y--;
   }
    ch = cin.get();
}
while(x!=0 and y!=0)
{
    if(x>0)
    { 
        s+='E';
        x--;
    }
    if(x<0)
    { 
        s+='W';
        x++;
    }
     if(y>0)
    { 
        s+='N';
        y--;
    }
    if(y<0)
    { 
        s+='S';
        y++;
    }

}
cout<<"final displacement is "<< s;
return 0;

}
WHY I am not getting the x and y units in terms of NSEW??.

Hello @shubham_jha please wait i am checking:

@shubham_jha check this:

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.