FINDING THE SHORTEST PATH

in the starting we have written the statement of ch=cin.get() and we are running the loop for if else statements .
NEW APPROACH- can’t we first run a loop to input the directions in the first step and then we give if else statements. NOTE: WE ARE NOT RUNNING LOOP FOR IF ELSE STATEMENTS IN THE NEW APPROACH WE ARE JUST RUNNING LOOP FOR TAKING INPUT OF DIRECTIONS.
char ch;
int n;
cout<<" enter the numbers of directions youu want: "<<endl;
cin>>n;
for(int i=1;i<=n;i++){
ch=cin.get();}

	    int x=0;
	    int y=0;
	  
	    if(ch=='N'){

	      y=y+1;
	      }
	    else if(ch=='S'){

	          y=y-1;
	         }
	    else if(ch=='E'){
	          x=x+1;

	         }
	     else {
	          x=x-1;

	         }
	   
	   

	   cout<<" the final x coordinate is: "<<x<<endl;
	   cout<<" the final y coordinate is: "<<y<<endl;

how to print directions instead of coordinates please help!!