Find the final co | C # implementation of the above approach ; Function to print the readonly position of the point after traversing through the given directions ; Traversing through the given directions ; If its north or south the point will move left or right ; If its west or east the point will move upwards or downwards ; Returning the readonly position ; Driver Code
using System ; class GFG { static void finalCoordinates ( int SX , int SY , char [ ] D ) { for ( int i = 0 ; i < D . Length ; i ++ ) { if ( D [ i ] == ' N ' ) { SY += 1 ; } else if ( D [ i ] == ' S ' ) { SY -= 1 ; } else if ( D [ i ] == ' E ' ) { SX += 1 ; } else { SX -= 1 ; } } String ans = ' ( ' + String . Join ( " " , SX ) + ' , ' + String . Join ( " " , SY ) + ' ) ' ; Console . Write ( ans ) ; } public static void Main ( String [ ] args ) { int SX = 2 , SY = 2 ; String D = " NSSE " ; finalCoordinates ( SX , SY , D . ToCharArray ( ) ) ; } }